日期:2014-05-16  浏览次数:20394 次

请梅花雪过来看,还是关于如何判断window.parent.opener是否关闭的问题!!!!!
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 ",为什么???

------解决方案--------------------
我也遇到相似问题

//初始化,把弹出的窗口对像给全局变量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;
}

}