在浏览器中返回/转发是否会更改javascript变量? [英] Does back/forward in the browser change javascript variables?
本文介绍了在浏览器中返回/转发是否会更改javascript变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<script type="text/javascript>
var x = 0; //this occurs in the beginning of the page.
$("#button").onclick{
x = 1;
}
</script>
假设变量x变为1.然后用户点击链接。当用户点击返回时,x是0还是1?
Let's say the variable "x" changes to 1. Then the user clicks a link. When the user clicks "back", will x be 0 or 1?
推荐答案
它将是 0
。浏览器不会缓存状态页面加载之间的Javascript变量。
It will be 0
. The browser does not cache the state of Javascript variables between page loads.
在浏览器中不是这种情况作为Firefox。请看Trey的回答。
This is not the case in browsers such as Firefox. Please see Trey's answer.
这篇关于在浏览器中返回/转发是否会更改javascript变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文