Solved

Auto Stop Loading Script ?

Posted on 2006-07-01
3
353 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
What is the normal amount of queries 5 84
Clean URL from GET variables 2 118
CSS HELP 6 93
cookies analysis tools 2 106
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

735 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