Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE 8 defaultView equivalent

Tags:

javascript

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.documentElement.ownerDocument.defaultView

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

like image 696
xdevel2000 Avatar asked Feb 19 '10 15:02

xdevel2000


2 Answers

parentWindow. So:

var doc = el.ownerDocument;
var win = ('defaultView' in doc) ? doc.defaultView : doc.parentWindow;
like image 60
bobince Avatar answered Oct 14 '22 09:10

bobince


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

should do the trick too.

like image 3
sajinshrestha Avatar answered Oct 14 '22 08:10

sajinshrestha