I was wondering whether the javascript objects kept accross pages? Looks like some browsers do and some dont. What is the standard behavior?
Thanks, Ebe
I was wondering whether the javascript objects kept accross pages? Looks like some browsers do and some dont. What is the standard behavior?
Thanks, Ebe
Never seen such a behavior. As far as i know - there aren't browsers that do this.
No, all objects will be lost when you change pages.
However, there is an interesting hack you can do with window.name
. The value of window.name
will remain for as long as the current window is open, so you can store data in it temporarily (and access it from page-to-page). However this data is accessible (and overwritable) from any page using that window, so it's not secure or reliable storage.
See http://www.thomasfrank.se/sessionvars.html for more info.
Some web browsers such as Safari cache the compiled javascript code. But state should not be persistent across page loads under any browsers.
Browsers do cache script files but the scope of JavaScript objects is limited to the page into which the script file is loaded, so that if you navigate to another page that uses the same script, the objects will be freshly created but not necessarily have the same state as in the previous page.