开发者

Find the window of an element inside an iframe

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

Thi开发者_开发技巧s 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;


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.


Use frame.contentWindow

var win = iframeElement.contentWindow;
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜