views:

33

answers:

2

Is there a cross browser method of returning the window object of an element whether it be in an iframe.

This does the job for me but I don't know how well supported it is or if jQuery has a solution.

var edoc = elem.ownerDocument.defaultView || elem.document.parentWindow;
A: 

Use frame.contentWindow

var win = iframeElement.contentWindow;
Andrew Dunn
Sorry, the element is inside the iframe. Don't have a reference the iframe.
Louis
+1  A: 

Your code should work in all major browsers. To clarify it - the first part is for non-IE browsers while the second targets IE. To the best of my knowledge jQuery does not provide a shortcut for that code.

korchev