7

Until all browsers support the onhashchange event what is the best workaround for this?

Is there something for this in jQuery? or as a plug-in?

balupton
  • 47,113
  • 32
  • 131
  • 182
MJLefevre
  • 815
  • 1
  • 8
  • 15
  • 1
    possible duplicate of [Detecting Back Button/Hash Change in URL](http://stackoverflow.com/questions/172957/detecting-back-button-hash-change-in-url) – Josh Stodola Sep 18 '10 at 09:58

6 Answers6

10

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

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

gurun8
  • 3,526
  • 12
  • 36
  • 53
8

Yes there is.

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

Piotr Rochala
  • 7,748
  • 2
  • 33
  • 54
6
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 fine for me across all tested (damn near all) platforms.

Mike
  • 61
  • 1
  • 1
1

Another library that abstracts url management is History.js

Tomasz Zieliński
  • 16,136
  • 7
  • 59
  • 83
0

If you're looking for an iframe cross domain solution this seems to be the most robust out there:
http://easyxdm.net/wp/
http://www.cakemail.com/the-iframe-cross-domain-policy-problem/

I haven't tried it though and it seems like it could be a bit difficult to implement and might not work in all situations.

tkane2000
  • 485
  • 5
  • 11