I am trying to get a hash value for the current page without success. I am targeting a page with a link, for example:
http://www.mydomain.com/test.html
My jquery for test.html is as follows:
$(document).ready(function() { if (window.location.hash){ console.log ("FOUND HASH"); }else{ console.log ("HASH NOT FOUND"); } });
No matter what I do, I never get a hash value; it's always empty. "However, when I break the code with Firebug and look at the DOM, I clearly see that the hash value is set correctly under window.location.hash .
What am I doing wrong?
Thanks in advance for your help.
ANSWER TO ANSWER: It turns out that masking my web address creates a frame wrapper around the entire page, in this case with different ports. The hash was preserved by the parent frame, but was lost for the child and is not accessible by jquery code. Using a direct non-loaded address led to the correct behavior.
source share