开发者

how to alert the script name that opened the window

开发者 https://www.devze.com 2023-01-02 08:37 出处:网络
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 r

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

精彩评论

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

关注公众号