Skip to content Skip to sidebar Skip to footer

Differences Between Chrome And Firefox: Reloading A Page Running A Javascript Game

I'm new to Javascript and web programming in general, so this may be a silly mistake. Nevertheless, I've had problems finding information about it. I am developing a game in Javas

Solution 1:

Sorry to abandon the question for so long, but I found a solution that worked!

I now call window.location.reload(true); before I call window.location = whateverUrl;

...I'm not sure why it works so well (I figured window.location.reload would reload the current page before going to the new one [that obviously isn't what I would want]), but it seems fine. It may be doing something I don't know behind my back I guess, but functionally it is doing what I want.

Solution 2:

I think that https://developer.mozilla.org/En/Using_Firefox_1.5_caching will answer all your questions. Firefox doesn't actually reload the page when going back, it rather restores it along with its JavaScript state. So you have several options:

  • Add an unload event handler to disable this behavior (suboptimal, degrades performance).
  • Use window.location.replace() instead of assigning to window.location, this will prevent the user from going back (undesirable I guess).
  • Add a pageshow event handler to reset JavaScript state.
  • Change the logic so that it no longer assumes that the user will go away and never return after clicking a link.

Post a Comment for "Differences Between Chrome And Firefox: Reloading A Page Running A Javascript Game"