开发者

IE 8 defaultView equivalent

开发者 https://www.devze.com 2022-12-20 13:07 出处:网络
I need from document object or from a DOM element (i.e. a DIV) to know which is its window object. In Firefox I can do:

I need from document object or from a DOM element (i.e. a DIV) to know which is its window object.

In Firefox I can do:

document.do开发者_开发技巧cumentElement.ownerDocument.defaultView

but obviously in that AWFUL browser that statement not work!!!


parentWindow. So:

var doc = el.ownerDocument;
var win = ('defaultView' in doc) ? doc.defaultView : doc.parentWindow;


var win = doc.defaultView || doc.parentWindow; 

should do the trick too.

0

精彩评论

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

关注公众号