window opener close issue for javascript

后端 未结 2 1760
庸人自扰
庸人自扰 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: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.

提交回复
热议问题