How Can a parent window know that its child window closed?

后端 未结 2 1992
刺人心
刺人心 2020-12-20 14:14

I want to execute a function when an opened child window is closed. Child window opening code is:

outWin = window.open (pageURL, title, \'toolbar=no, location         


        
2条回答
  •  南方客
    南方客 (楼主)
    2020-12-20 14:47

    You can try acces the parent window by:

    window.opener.functionThatYouWant();
    

    This code is inside de child window.

    But if you open an window that the URL is in another domain (not localhost), you can't access it because of security issues.

    I used this code on Firefox, I am not sure if it works crossbrowser.

提交回复
热议问题