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 dow the parents sperdow the parent to window the parents sdow the parents”是一些意思.可以透過iframeElement.contentDocument.parentWindow取得iframe的window物件。但經過測試firefox、chrome的element.contentDocument物件沒有parentWindow屬性。
(javascript)
存在跨域存取限制。
chrome:iframeElement.contentDocumentfirefox:iframeElement.contentDocument
備註:ie沒有iframeElement.contentDocument屬性。
(javascript)
存在跨域存取限制。
父頁:window.parent頂層頁面:window.top
4. 取得iframe在父頁中的html標籤
存在跨域存取限制。
window.frameElement(類型:HTMLElement),適用於所有瀏覽器
5. iframe的onload事件
非ie瀏覽器都提供了onload事件。例如下面程式碼在ie中是不會有彈出框的。
(javascript)
6. frames
window.frames可以取到頁面中的幀(iframe、frame等),需要注意的是取到的是window對象,而不是HTMLElement。