Skip to content
Advertisement

After travelling back in Firefox history, JavaScript won’t run

When I use the back button on Firefox to reach a previously visited page, scripts on that page won’t run again.

Is there any fix/workaround to have the scripts execute again when viewing the page the second time?

Please note that I have tested the same pages on Google Chrome and Internet Explorer and they work as intended.


Here are the files and the steps I used to test the problem:

(navigate to 0.html, click to get to 1.html, back button)

0.html

JavaScript

1.html

JavaScript

Advertisement

Answer

Set an empty function to be called on window.onunload:

JavaScript

e.g.

JavaScript

Source: http://www.firefoxanswer.com/firefox/672-firefoxanswer.html (Archived Version)

Advertisement