[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

JavaScript: Loaded from web server or local computer?

Posted on 2011-09-29
1
Medium Priority
?
154 Views
Last Modified: 2012-05-12
Using JavaScript, how can I detect if a page was loaded from a web server or from a folder on a person's computer?

if( served_from_web_server ) alert('This page was loaded from a web server.');
else alert('This page was loaded locally');

Open in new window

0
Comment
Question by:hankknight
1 Comment
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 36815640


if( location.href.indexOf("http") == 0 ) alert('This page was loaded from a web server.');
else alert('This page was loaded locally');
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

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…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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

834 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