Components.utils.getGlobalForObject 编辑
This method is used to determine the global object with which an object is associated. This is the global object in place at the time the object was created, which is to say the global object used when executing the script that created the object.
Syntax
var global = Components.utils.getGlobalForObject(obj);
Parameters
obj
- an object whose corresponding global object is to be retrieved; non-optional, must be object-valued
Example
var obj = {}; function foo() { } var global = this; var g1 = Components.utils.getGlobalForObject(foo); var g2 = Components.utils.getGlobalForObject(obj); // g1 === global, g2 === global, g1 === g2 // In a script in another window var global2 = this; function bar() { } var obj2 = {}; // Then, assuming bar refers to the function defined in that other window: var o1 = Components.utils.getGlobalForObject(bar); var o2 = Components.utils.getGlobalForObject(obj2); // o1 === global2, o2 === global2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论