jjacquay712 Posted June 24, 2009 Share Posted June 24, 2009 I am starting to see many web applications like gmail and facebook use the url hash to dynamically change the page. Ex. http://mail.google.com/#inbox How could you make an event handler call when ever the anchor changes? OnLoad doesn't work because it isn't called when the anchor changes. You can get the text of the anchor using location.hash. Thanks, John Quote Link to comment Share on other sites More sharing options...
jjacquay712 Posted June 24, 2009 Author Share Posted June 24, 2009 I figured out how to do! You have to check or "poll" every set amount of time to see if location.hash is different then what is was last. Here is my code if anyone is interested: var lasthash = ""; function init() { //Call when page loads setInterval("checkHash()", 100); } function checkHash() { if ( lasthash !== window.location.hash ) { lasthash = window.location.hash; ajaxNavigate(lasthash); //This function uses ajax to update the page } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.