Постоянная загрузка в URL-адресах «AJAX» с jQuery в Firefox
-
26-09-2019 - |
Вопрос
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 делает Firefox на Mac выглядеть только так, как будто она постоянно перезагружается. На Firefox на W7 он не и хром на обоих OSS работает нормально. Как я могу заставить его перестать выглядеть как это загрузка в потрясающем баре на Firefox?
Fyi, я делаю это, так что функциональность кнопки назад / вперед работает ...
Решение
Попробуй это:
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);
}
Не связан с StackOverflow