在登录页login.aspx的<head></head>中有这样一段javascript代码
function OpenWindow(URL)
{
var Features='toolbar=0,location=0,directories=0,menubar=0,scrollbars=auto,resizeable=1,status=1';
window.open(URL,"main",Features);
top.opener=null;
top.close();
}
在</body>后有这样一段javascript代码
if (top!=self)  //这一段代码用意是:我用了框架,如果用户超时,或者被管理员强制下线就会重定向到login.aspx,我这样
{               //做的目的就是关闭原来用OpenWindow打开的窗口,并在正常的IE窗口中显示登录窗口
window.open('login.aspx');  //因为在OpenWindow打开的窗口内,再次用OpenWindow打开窗口,IE就自动关闭了。
top.opener=null;
top.close();
}
在提交按钮事件(服务器端)内有
page.clientscript.RegisterStartupScript(me.gettype(),"logd","OpenWindow('"+URL+"');",true)
问题出来了
单击按钮后,这个按钮的单击事件会连续地执行两次,但如果我把</body>后的这一段代码注释掉,就正常了。哪位高手能告诉我原因和解决办法,目前我的办法是,在这个事件内设了一个静态变量,第二次进入事件就退出不做处理。不知道我有没有讲清楚.

解决方案 »

  1.   

    晕了.
    我的理解为:父窗口打开个子窗口,当超时或什么的 父窗口跳转,子窗口关闭.
    <html>
    <head>
        <title>无标题页</title>
        <script language="javascript" type="text/javascript">
            var sonWindow;
            function Click_Open()
            {
                sonWindow = window.open('index.html');
            }
            function Click_LoClose()
            {
                sonWindow.close();
                location='cc.html';
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <button onclick="Click_Open();">打开</button>
            <button onclick="Click_LoClose();">模拟跳转,关闭</button>
        </div>
        </form>
    </body>
    </html>