Close child window, redirect parent window

后端 未结 4 997
庸人自扰
庸人自扰 2020-12-14 08:24

I\'ve got a page which opens a child window, from a parent.

After the user has done something in the child window, I need the child window to close, and its parent w

相关标签:
4条回答
  • 2020-12-14 08:32

    The key is to use window.opener to access the parent window:

    <script>
        window.opener.location = '/redirect.html';
        window.close();
    </script>
    
    0 讨论(0)
  • 2020-12-14 08:36

    from child:

    opener.location.href = '/redirect';
    close();
    
    0 讨论(0)
  • Please try below :

    window.opener.location.reload();
    close();
    
    1. window.opener.location.reload(); will reload the parent window.
    2. close() will close the child window

    It works fine for me.

    0 讨论(0)
  • 2020-12-14 08:40

    try this:

    var parent = window.opener;
    
    parent.location ='some url';
    
    window.close();
    

    here is an example in a fiddle: http://jsfiddle.net/maniator/jGbZq/

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