Molly
Molly

Reputation: 297

Javascript not executed after using window.location.hash

I need to redirect the user to another page, I have used window.location.hash = "../pagePath.html"; but it does redirect to the page without firing the JavaScript code, is some jQuery Mobile solution for this? something like "ajax-false" that I can use in JS code?

Upvotes: 0

Views: 489

Answers (1)

Virus
Virus

Reputation: 2541

you need to use

window.location.href="../pagePath.html";

whereas

window.location.hash 

will return the anchor value from the url. for Ex.: your browser url is www.google.com/accounts#gmail then if you get the window.location.hash like this

var anc=window.location.hash;

then and will return "gmail".

Upvotes: 3

Related Questions