Solved

Auto Stop Loading Script ?

Posted on 2006-07-01
3
352 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
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

856 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