Solved

Auto Stop Loading Script ?

Posted on 2006-07-01
3
354 Views
Last Modified: 2010-04-06
I need a script that if user reached it ( without clicking or pressing ), it will stop loading the page.
Is it avaiable ? Can you explain for me ?
0
Comment
Question by:vmyth
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 30

Accepted Solution

by:
callrs earned 250 total points
ID: 17025533
>>without clicking or pressing
If you want to prevent user from typing in http://url/myscrip.js, then I doubt it's possible (you can obfuscate the code to stop the casual observer though)
But if you want to prevent user from accessing an HTML page that has your javascript code embedded in it, try this:

Use a form with onclick events for buttons & links. When form is submitted, form field data gets inserted into the url. e.g. "http://www.google.com/search?q=javascript"
So if user just types in the base url, your script can check the url & so will know that the page was not reached using a particular button or link.

Won't stop them from typing in the url with the proper input after the '?', but it makes it less convenient for them. But you can set a value that MUST exist in the url, e.g. a really long complex value that no user would want to type out, and set it as a hidden element in the form. That value gets appended to the url when form is submitted via a click.

E.g. run the following example, and look at the url in the address bar after you click

<html>
<!-- Submit via link and submit button - Demo,
      by Ravinder Singh ('wiz' @ the quickmacros forum), 2006-07-01

      Select, copy,paste into notepad, save as c:\temp\google.htm
      Then type that path into address bar in your browser -->

<form name="magic" target=_self method="GET" action="http://www.google.ca/search">
<input type=submit name="sendme" value="Google.ca">
<input type=text name=q size=31 maxlength=2048 value="key" title="Search">
</form>
<a href="#" onclick="document.magic.action='http://www.google.com/search';document.magic.submit();"><B>Search Google.com</B></a>
</html>
0
 
LVL 30

Expert Comment

by:callrs
ID: 17162685
Any update?
0
 

Author Comment

by:vmyth
ID: 17162763
I'm sorry I forgot to click the "Accept" button :D
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows Standards for file storage. 3 38
PHP email variable syntax 3 53
Collapseable list of URLs. 10 144
Make Line Items Look Good Over Mobile 2 126
Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to count occurrences of each item in an array.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question