javascript - Closing window from another window -


there 2 child windows b , c. , parent window a. want close c window when user clicks button in b.

window.opener() gives reference parent object. testing purposes lets assume c window name "name". below code invoked b should close c window.

but doesn't work.

  var windowobjectreference = window.opener.open("www.google.com" , "name");   windowobjectreference.close(); 

any idea how this?

since parentwindow has reference child windows, use parent window set handler of button in b child window. like:

var windowb = window.open( ... ),     windowc = .... ,     buttonb = windowb.document.queryselector(...yourbuttonreference...); buttonb.onclick = function() {     windowc.close();     window.open('http://www.google.com'); } 

if don't want close c window, try replacing window.location of c window google. parent window has references, it's easier have parent window opening/closing instead of having child windows try access siblings.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -