Question

I'm trying to see which windows are being opened, but I dont know the window names as they are called.

How can I access them in JAVASCRIPT/DOM/or JQUERY?

Thanks!

Was it helpful?

Solution

Every example I've seen requires the name of the window. If you can't control that yourself, because you're using a complicated/obfuscated library or a generic greasemonkey script for a complicated website, say, you could try and monkey patch the places the window is opened. Assuming windows are all opened via window.open, you could do:

var allWindows = []
var _windowOpen = window.open;
window.open = function() {
  var newWindow = _windowOpen.apply(this, arguments);
  allWindows.push(newWindow);
}

allWindows will then contain the list of all windows that have been opened so far. You can loop through them at any time and check the "closed" property to find those that are still open. i.e. you deduce a window is open if !win.closed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top