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('#!/')[1]);
current_url = window.location.hash.href;
}
},100)
我的 JavaScript/jQuery 的这一部分使得 Mac 上的 Firefox 看起来只是在不断地重新加载。在 W7 上的 Firefox 上则不然,在两个操作系统上的 Chrome 上也都可以正常工作。我怎样才能让它看起来不再像在 Firefox 上的很棒的栏中加载一样?
仅供引用,我这样做是为了让后退/前进按钮功能起作用......
最佳答案
试试这个:
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);
}
关于javascript - 在 Firefox 中使用 jQuery 持续加载 "AJAX"URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4218374/