开发者

Constant Loading in "AJAX" URLs with jQuery in Firefox

setInterval(function(){
  if(current_url == ''){
    window.location.hash = '#!/home';
    current_url = window.location.hash.href;
  }
  else if(current_url !== window.location){
    change_page(window.location.hash.split('#!/'开发者_StackOverflow)[1]);
    current_url = window.location.hash.href;
  }
},100)

This part of my JavaScript / jQuery makes Firefox on Mac only look like it's constantly reloading. On Firefox on W7 it doesn't and Chrome on both OSs it works fine also. How can I make it stop looking like it's loading in the awesome bar on Firefox?

FYI, im doing this so back/forward button functionality works...


Try this:

var hashChanged = function() {
  if(current_url == '') {
    window.location.hash = '#!/home';
    current_url = window.location.hash;
  }
  else if(current_url !== window.location.hash){
    change_page(window.location.hash.split('#!/')[1]);
    current_url = window.location.hash;
  }
};

if('onhashchange' in window) {
    window.onhashchange = hashChanged;
} else {
    setInterval(hashChanged, 100);
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜