Check if an HTML file is online or local folder

javascript

Solution

window.location.protocol

can give you whether the file is local ("file:") or website ("http:")

Which is implemented by window.location

Problem

i'm loocking for a javascript code (if it's possible) to check if an HTML file has been launched/read from a remote host or from a local folder of pc. ..let me explain better with an example: i've an html file in C:/folder/file.html if i launch it by double-clicking, a js script print "read from local" on the document. Now, if i host it on a my website, like www.mydomain.org/file.html and open that page, the js script print "read from online" This would be greatly helpful, thank you for now.

Original source