window opener close issue for javascript

后端 未结 2 1757
庸人自扰
庸人自扰 2020-12-12 03:13

I have a problem with browsers window managament with javascript. I have two page in my proof of concept application. First page contains login information (username, passwo

相关标签:
2条回答
  • 2020-12-12 03:41

    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.

    0 讨论(0)
  • 2020-12-12 03:51

    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.

    0 讨论(0)
提交回复
热议问题