js操作iframe小技艺

js操作iframe小技巧1. 获得iframe的window对象存在跨域访问限制。chrome:iframeElement. contentWindow fir

js操作iframe小技巧
1. 获得iframe的window对象

存在跨域访问限制。

chrome:iframeElement. contentWindow
firefox: iframeElement.contentWindow
ie6:iframeElement.contentWindow

文章Iframes, onload, and document.domain中说“he iframe element object has a property called contentDocument that contains the iframe’s document object, so you can use the parentWindow property to retrieve the window object.”意思就是一些浏览器可以通过iframeElement.contentDocument.parentWindow获得iframe的window对象。但经过测试firefox、chrome的element.contentDocument对象没有parentWindow属性。





1楼lidaasky昨天 22:23
学习了