Let assume page url /xyz. I have window object declared at the top of my JS (because I need that throughout) like
window.myObject={
someWork:true
}
and I am changing the property value like
if(window.myObject.someWork){
//Do Work
window.myObject.someWork=false
}
When I click back button from some other page (abc->xyz) my window.myObject.someWork
remains false instead of getting re-initialised again at the top (because I think refresh will run the script again). Can you please suggest what is happening around and how to fix this.
Went through this Does back/forward in the browser change javascript variables?. Any fix for this? I am using Chrome and would like to make it work on all browsers
Fixed: Xufox solution is good and worked.It also cache DOM elements on back button. So make sure its not screwing up the code :)
Thanks in advance