JavaScript / jQuery - onhashchange workaround

While all browsers do not support the onhashchange event, what is best suited for this?

Is there anything for this in jQuery? or as a plugin?

+7
javascript jquery events fragment-identifier hashchange
source share
6 answers

Not sure if this is what you are looking for or not, but worth a try:

http://plugins.jquery.com/project/ba-jquery-hashchange-plugin

+10
source share

Yes there is.

Check out this jQuery plugin: http://benalman.com/projects/jquery-hashchange-plugin/

+8
source share
var lastHash = ""; window.onload=function() { hashChangeEventListener = setInterval("hashChangeEventHandler()", 50); } function hashChangeEventHandler() { var newHash = location.hash.split('#')[1]; if(newHash != lastHash) { lastHash = newHash; //Do stuff! } } 

Works great for me on all tested (damn almost all) platforms.

+6
source share
+1
source share

Another library that abstracts URL management, History.js

+1
source share

If you are looking for a cross-domain iframe solution, this is apparently the most reliable:
http://easyxdm.net/wp/
http://www.cakemail.com/the-iframe-cross-domain-policy-problem/

I have not tried this, although it seems that it can be a little difficult to implement and may not work in all situations.

0
source share

All Articles