How to run function of parent window when child window closes?

前端 未结 7 2265
余生分开走
余生分开走 2020-11-29 02:15

I am calling the javascript window.open() function to load another url in a pop up. Once the users is finished it takes them to the last page that has a link that says close

7条回答
  •  孤城傲影
    2020-11-29 02:52

    This is an old post, but I thought I would add another method to do this:

    var win = window.open("http://www.google.com");
    
    var winClosed = setInterval(function () {
    
        if (win.closed) {
            clearInterval(winClosed);
            foo(); //Call your function here
        }
    
    }, 250);
    

    You don't have to modify the contents or use any event handlers from the child window.

提交回复
热议问题