开发者

how to alert the script name that opened the window

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


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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜