Question

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)

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...

Was it helpful?

Solution

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);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top