views:

24

answers:

1

I am using multiple scripts to get to a sub window. I want to know how to alert the parent window name. is there anything like alert(window.opener)?

+1  A: 

Yes, window.opener exists as a reference to the window that opened the current window. It's supported in at least Chrome, Firefox, IE and Opera.

https://developer.mozilla.org/en/DOM/window.opener
http://msdn.microsoft.com/en-us/library/ms534309(VS.85).aspx

If you're looking to get a reference to the function that created the window, you could add it yourself as a property of the window:

var win = window.open("test.htm", "myWin");

// set a global var in the window to this function
win.openerFunction = arguments.callee;
Andy E