tags:

views:

112

answers:

1

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!!!

+1  A: 

parentWindow. So:

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