I want to get the references of all already opened child windows. is there any way? I am not using child = window.open(....)
just using window.open(....)
and opening multiple child windows.
The syntax to open a popup is: window. open(url, name, params) : url.
You just need to prefix “ window. opener. ” and write the same code that you will write in the parent window's HTML page to access its elements.
From a child window or a small window once opened, we can transfer any user entered value to main or parent window by using JavaScript. You can see the demo of this here. Here the parent window is known as opener. So the value we enter in a child window we can pass to main by using opener.
If you open all child windows with window. open, include this javascript in all pages, then CloseAll(false); from any included page will close all child, grandchildren, great-grand... etc., and redirect the first (root) page to login.
If you don't want to change your current code, you can simply override window.open()
function:
var openedWindows = []; window._open = window.open; // saving original function window.open = function(url,name,params){ openedWindows.push(window._open(url,name,params)); // you can store names also... }
Run this code before calling window.open()
. All the references to the opened windows will be stored in openedWindows
array. You can access them anywhere you want
I don't believe you can, unless you know the windows' names, which I'm guessing you don't. (If you know their names, you can use window.open("", "name")
to get a reference to them.)
The better option is, of course, to remember the reference returned from window.open
in the first place — but you know that. :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With