Reputation: 5890
Hi all I have variable defined in one js file. Now from this js file I am navigating page to one html file and I want to access that variable in that html file. I use window.location as:
window.location = "UI/demo/home.html";
But in home.html when I tried to access that variable which is declared in js file I got variable as undefined. If I use changePage instead of window.location I got value of variable. Why is it so? Any suggestion will be appreciated. Thanks in advance.
Upvotes: 0
Views: 1680
Reputation: 944
changePage
changes the DOM of the page without reloading the loaded Javascript. window.location
changes the page of the browser itself, reloading all content, including Javascript.
So while the two may seem to have the same effect, changePage
is probably what you are looking for except in the cases where you want to deliberately reload the URL.
Also note that changePage
has a reloadPage
argument that basically does what window.location
would without fancy animations, etc.
http://jquerymobile.com/test/docs/api/methods.html
Upvotes: 1