how to close the child window when closing parent window in javascript? -


How to turn off the hair window while closing the original window in Javascript

< Div class = "post-text" itemprop = "text">

If you open a pop-up window and window with parents and child's windows, then you can not do this at all, but the following script will be main The window will close the pop-up window when the main window is loaded (either closes or the user (Navigate to another page or refresh):

  var popup = window.open ("popup. Html", "popup", "width = 300, height = 200"); Window.onunload = function () {if (Popup and PopUp.closed) {popUp.close (); }};  

Historical Note: It was possible to do this in some browsers (such as Firefox) by using the dependent window property in the third parameter of > Window.open call (such as var popup = window.open ("popup.html", "popup", "width = 300, height = 200, dependent"); ) but now it's nothing I have not tested it myself.


Comments