Carregamento constante em URLs “Ajax” com jQuery no Firefox
-
26-09-2019 - |
Pergunta
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)
Esta parte do meu JavaScript / JQuery faz o Firefox no Mac apenas parece que está constantemente recarregando. No Firefox, no W7, não faz o Chrome em ambos os OSS também funciona bem. Como posso fazer parar de parecer que está carregando no incrível bar no Firefox?
Para sua informação, estou fazendo isso para que a funcionalidade do botão de volta/avanço funciona ...
Solução
Experimente isso:
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);
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow