在浏览Firefox历史记录之后,JavaScript将无法运行 [英] After travelling back in Firefox history, JavaScript won't run
问题描述
当我使用Firefox上的后退按钮访问先前访问过的页面时,该页面上的脚本将不会再次运行。
是否有任何修复/解决方法在第二次查看页面时再次执行脚本?
请注意,我测试了相同Google Chrome浏览器和Internet Explorer上的网页,并按预期工作。
以下是我用来测试的文件和步骤问题:
$ b
(导航到0.html,单击以获得1.html,返回按钮)
0.html
< html>< body>
< script>
window.onload = function(){alert('window.onload alert'); };
alert('inline alert');
< / script>
< a href =1.html>点击我!< / a>
< / body>< / html>
1.html
< html>< body>
Go Back!< / p>
< / body>< / html>
设置一个空函数window.onunload:
window.onunload = function(){}
< HTML><身体GT;
< script type =text / javascript>
window.onload = function(){alert('window.onload alert'); };
window.onunload = function(){};
alert('inline alert');
< / script>
< a href =1.html>点击我!< / a>
< / body>< / html>
来源: http://www.firefoxanswer.com/firefox/672-firefoxanswer.html (存档版本)
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
<html><body>
<script>
window.onload = function() { alert('window.onload alert'); };
alert('inline alert');
</script>
<a href="1.html">Click Me!</a>
</body></html>
1.html
<html><body>
<p>Go BACK!</p>
</body></html>
Set an empty function to be called on window.onunload:
window.onunload = function(){};
e.g.
<html><body>
<script type="text/javascript">
window.onload = function() { alert('window.onload alert'); };
window.onunload = function(){};
alert('inline alert');
</script>
<a href="1.html">Click Me!</a>
</body></html>
Source: http://www.firefoxanswer.com/firefox/672-firefoxanswer.html (Archived Version)
这篇关于在浏览Firefox历史记录之后,JavaScript将无法运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!