window opener close issue for javascript

余生长醉 提交于 2019-11-28 14:24:50

You cannot do it according the security assurance of browser, there are some action which doesn't allow to be managed directly via javascript without user interference.

Try something like this in your new window, on the body onload:

function closeParent()
{ 
    try
    { 
        var op = window.opener; 
        op.opener = self; 
        op.close();              
    } 
    catch(er) {} 
}

Still, this solution isn't perfect, I only got it to work in Internet Explorer, and even then, I got a warning popup for closing the parent window. This might be something that can't feasibly be solved.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!