?
Solved

Auto Stop Loading Script ?

Posted on 2006-07-01
3
Medium Priority
?
356 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 1000 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

770 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