Javascript 使用back键返回页面后,索引未重置为0

Javascript 使用back键返回页面后,索引未重置为0,javascript,Javascript,下面是制作跳转菜单的脚本。我使用javascript将选项标记的索引设置为等于0。除了一个之外,scrip工作正常。从跳转菜单跳转到另一个页面后,索引不会重置为索引0。而是设置为我单击的索引。为什么会这样?脚本有什么问题 脚本: window.onload = startInit; function startInit() { document.getElementById("newLocation").selectedIndex = 0; document.getElementById("n

下面是制作跳转菜单的脚本。我使用javascript将
选项
标记的索引设置为等于0。除了一个之外,scrip工作正常。从跳转菜单跳转到另一个页面后,索引不会重置为索引0。而是设置为我单击的索引。为什么会这样?脚本有什么问题

脚本:

window.onload = startInit;

function startInit() {
document.getElementById("newLocation").selectedIndex = 0;
document.getElementById("newLocation").onchange = jumpPage;
}

function jumpPage() {
var newLoc = document.getElementById("newLocation");
var newPage = newLoc.options[newLoc.selectedIndex].value;
if(newPage != "")
   window.location = newPage;
}
HTML

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="script.js">
</script>
</head>

<body bgcolor="#FFFFCC">
<center>
<form>
<select id="newLocation">
 <option value="myworld.gif">first</option>
 <option value="myhome.gif">second</option>
 <option value="myroom.gif">third</option>
 <option value="mybed.jpg">fourth</option>
</select>
</form>

无标题文件
第一
第二
第三
第四

浏览器操作智能并缓存您的页面。因此,您可以看到缓存版本的 为了确保这种情况不会发生,您总是从 第0个索引,告诉浏览器在页面打开时不要做任何事情(按您希望的方式) 卸载

声明应为:
window.onunload=function(){};//不执行任何操作功能

您可以在
window.onload=startInit之后添加

这会告诉浏览器卸载过程中发生了什么,因此 应该重新阅读该页。

是的,和/或您可以添加。