用的是框架
左边,left页面:
function setCookie(name,value,h)
{
var exp = new Date();
exp.setTime(exp.getTime() + h * 60 * 60 * 1000);
document.cookie = name + "= "+ escape (value) + ";expires= " + exp.toGMTString();
}
function openLink(url)
{
setCookie( "myframe ", "left ", 1);
window.parent.frames[ "mainFrame "].location.href = url;
}
中间页面
function window_onload()
{
var myframe = getCookie( "myframe ");
var exp = " ";
if (myframe && (myframe == "left "))
{
exp = selexpect;
}
else
{
if (getCookie( "DadiZcExpect ") && (getCookie( "DadiZcExpect ") != " "))
exp = getCookie( "DadiZcExpect ");
else
exp = selexpect;
}
setnselect( "expect ", exp);//设置当前期
if (getCookie( "zcgid ") && (getCookie( "zcgid ") != " "))
GradeClick(getCookie( "zcgid "));
else
GradeClick(1);
setCookie( "myframe ", "center ", 1);
alert(getCookie( "myframe "));
}
点击左边的菜单,然后中间显示,执行window_onload();
可是alert出来的值一直是left,请问什么原因?
后来在onunload()事件里也不行
function window_onunload()
{
setCookie( "myframe ", "left ", 1);
}
郁闷。
------解决方案--------------------
看贴了
------解决方案--------------------
function setCookie(name,value,h)
{
var exp = new Date();
exp.setTime(exp.getTime() + h * 60 * 60 * 1000);
document.cookie = name + "= "+ escape (value) + ";expires= " + exp.toGMTString();
}
这个在中间的页面写没?
------解决方案--------------------
get的那个方法是怎么写的啊,我测试了下,没有你说的情况发生啊!帖出测试的代码
三个文件,直接考下去存成文件就可以了
main.htm
<frameset cols= "100,* " name= "ddd ">
<frame src= "4.htm ">
<frame name= "mainFrame " src= "about:blank ">
</frameset>
4.htm*************************************************************
<SCRIPT>
function setCookie(name,value,h)
{
var exp = new Date();
exp.setTime(exp.getTime() + h * 60 * 60 * 1000);
document.cookie = name + "= "+ escape (value) + ";expires= " + exp.toGMTString();
}
function openLink(url)
{
setCookie( "myframe ", "left ", 1);
top.mainFrame.document.location.href = url;
}
</SCRIPT>
<a href= "# " onclick= "openLink( '3.htm ') "> asdasdasd </a>
3.htm********************************************************************
<script language=javascript>
function setCookie(name,value,h)
{
var exp = new Date();
exp.setTime(exp.getTime() + h * 60 * 60 * 1000);
document.cookie = name + "= "+ escape (value) + ";expires= " + exp.toGMTString();