Reputation: 13848
Suppose I'm in page0
and call this javascript:
window.flag = 1
and then navigate away to page1
and hit the back button. When page0
loads, but before the flag is set, will window.flag
still be 1
, or will it be undefined
? In other words, does window state for a page persist?
I would have thought this was a very simple thing to clarify, but I can't find documentation about it anywhere.
Upvotes: 1
Views: 489
Reputation: 5712
No.
JavaScript is client-side and non-persistent. Unless you actively save values somehow, the results of called JavaScripts are not retained.
If you do want to save a value or object, look into localStorage
or cookies.
Upvotes: 2