时间:2021-07-01 10:21:17 帮助过:15人阅读
<script type="text/javascript">
window.onload = function () {
var cooki = document.cookie;
if (cooki != "") {
cooki = "{\"" + cooki + "\"}";
cooki = cooki.replace(/\s*/g, "").replace(/=/g, '":"').replace(/;/g, '","');
var json = eval("(" + cooki + ")"); //将coolies转成json对象
document.getElementById("selectID").options[json.selIndex].selected = true;//保持原来的选项
}
else
save();
}
function change()
{
selectIndex = document.getElementById("selectID").selectedIndex;
document.cookie = 'selIndex =' + selectIndex;//保存在cookie中,键名为selIndex
}
</script>