VerySource

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1672|回复: 1

关于如何判断window.parent.opener是否关闭的问题!!!!!

[复制链接]

2

主题

6

帖子

5.00

积分

新手上路

Rank: 1

积分
5.00
发表于 2020-3-19 23:00:02 | 显示全部楼层 |阅读模式
function shutwin()
{
     var wp = window.parent.opener;
        if(wp!=null && typeof(wp) != "undefined" && !wp.closed)
        {     
            if (wp.document.forms[0].txtRefreshParent != null)
            {
                wp.document.forms[0].txtRefreshParent.value="Refresh";
            }
            else
            {
               if(wp.document.forms[0].ctl00_MainPlaceHolder_txtRefreshParent!=null)
               {
                   wp.document.forms[0].ctl00_MainPlaceHolder_txtRefreshParent.value="Refresh";
               }
            }
            wp.document.forms[0].submit();
        }
    window.parent.close();
}
事实上wp已经关闭,但是wp.closed为什么等于true呢,且typeof(wp)="object",为什么???
回复

使用道具 举报

0

主题

1

帖子

2.00

积分

新手上路

Rank: 1

积分
2.00
发表于 2020-7-30 16:30:01 | 显示全部楼层
我也遇到相似问题

//初始化,把弹出的窗口对像给全局变量attach
//var timer;
var attach;
function initWin(obj){
        attach = obj;
        attach.focus();       
        //设置定时执行函数的时间
        timer=window.setInterval("IfWindowClosed()",500);       
}

//判断窗口是否关闭
function IfWindowClosed() {
        //alert();//如果把alert运行,下面那句就不会提示没权限,就可以正常运行
        if (attach.closed) {//这句提示没有权限
                window.location=window.location;
                window.clearInterval(timer);
                attach = null;
        }

}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

快速回复 返回顶部 返回列表