开发者

Does onHashChange work in Safari?

Does onHashChange or hashChange work in Safari? I tested it with Safari 4.0.4 on Windows 7 and it doesn't work for me.

If it doesn't w开发者_StackOverflow中文版ork, is there any solution to track if the hash has changed?


In our app we poll to check for changes:

$b.hashCheck = setInterval(
    function(){
        if ( window.location.hash !== $b.C.current_hash){
            $b.C.current_hash = window.location.hash;

            //call the on change action here

        }
    },$b.C.hashCheckDelay
);

$b is the global object we use for our namespace and hashCheckDelay was empirically set at 120ms.
While it looks a bit sad to do this kind of process, there isn't any performance issue on any browser we tested.


In Safari 4.0.4 it's not working yet but in the latest one works fine. And I didn't find any acceptable solutions to track if the hash has changed for those browsers which don't support onHashChange.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜