2013-08-21 45 views
1

內我有我的網站的結構如下:獲得瀏覽器窗口的高度可用的I幀從

<html> 
    <iframe> 
    <iframe> 
    </iframe> 
    </iframe> 
<html> 

我prgramming最內iframe的一部分。現在我想確定瀏覽器窗口的可用height(從menubar開始並在可能的toolbars之前結束)。

IE9,並試圖像財產以後:

window.innerHeight 

(結果未定義)和

window.parent.document.body.clientHeight 

(不是高度我預期)

如何獲得height?提前Thanx。

回答

4

window.parent.document.body.clientHeight

(不是高度我預期)。我如何獲得身高? Thanx在 前進。

這是因爲window.parent將是它上面的iframe,而不是頂級。

你想用window.top

+0

window.top.document.body.clientHeight給我和window.parent.document.body.clientHeight一樣高......並且這個高度太小了 – zuluk

+0

我相信你應該在非IE瀏覽器中使用innerHeight – epascarello

+0

對我來說非常合適!這裏是我所有的代碼:'window.parent.innerHeight'爲我節省了大量的時間!非常感謝! – www139

0

還要注意的是window.parent是對window對象的託管文件的引用。所以你可以做window.parent.innerHeight(或window.top.innerHeight

儘管沒有單一的方式獲取文件窗口的高度,見Get the size of the screen, current web page and browser window一個快速,跨瀏覽器的解決方案和更詳細的解釋

+0

window.top.innerHeight:我只是用IE9得到「undefined」。 – zuluk

0

我嘗試了一下,發現下面一個爲我工作的解決方案:

top.document.getElementsByTagName("html")[0].offsetHeight 
相關問題