Quote:
Originally Posted by WolfShade
However, I tried testing with a .htm document that I created (via NotePad) on my Desktop, and it's not working.. at all.
For localStorage, is location going to determine if it's going to work? Will it not work, if it's on the same machine from which I am testing?
Thank you,
|
How are you accessing the local file? I would expect that if you are running a local server and access the page via http://localhost that it should work exactly the same on your computer as it does if uploaded to a remote server.
There are a growing number of things in JavaScript that behave differently if the script is running via a web server (whether local or remote) to how it runs if you try to just access the file locally. Some browsers eg. IE will not allow any JavaScript at all to be run outside of a server unless you specifically allow it each time you want to run it and then it may not run the same as it would on a server.
While it is obvious that cookies will not work if you try to run the page directly without a web server as the cookies get passed to and from the server it isn't as obvious why localStorage should have the same restriction except that the security is supposed to work based on the domain name and pages run directly don't have a domain name (which is one possibility as to why it doesn't work outside a server).