這個問題似乎很難理解,所以我會盡我所能對它進行說明。HTML5從嵌套的iframe中調整頂級文檔iframe
說我有以下的index.html體:
<iframe name="parent"></iframe>
而且parent
iframe中,我加載以下頁面體:
<iframe name="nested-navigation"></iframe>
<iframe name="nested-parent"></iframe>
而且裏面nested-parent
iframe中,我打開另一個頁面。在這個其他頁面中,我需要以某種方式獲取iframe的頂級(index.html)文檔parent
,以便我可以使用iframe內容大小nested-parent
調整其內容的高度。
我使用嵌套的頁面主體的加載內容正確調整了index.html的iframes高度的parent
的大小。但是,在下一個嵌套中,我無法訪問index.html
文檔上下文,因此無法獲取iframe元素。
我需要幫助弄清楚如何到達index.html的iframe的parent
。我將如何做到這一點?
頁面在線和效果可以看這裏:
www.ngeneersinc.com
如果單擊Projects
導航鏈接,它會正確地加載網頁並調整parent
iframe中。遺憾的是,當您點擊此嵌套頁面中的Ngen
導航鏈接時,頂級(index.html)iframe(parent
)沒有調整大小,並且內容被剪切爲上一頁中設置的高度。
編輯:
從本質上講,我試圖做我的javascript函數如下:
var e = document.getElementById("nested-parent").contentWindow; // which is OK
var x = e.contentWindow; // which is 'undefined' because I lost the context of the index.html document
我沒有使用上面的所有代碼,但是我找到了我需要的部分。 謝謝! –