从 iframe 中获取浏览器窗口的可用高度

zul*_*luk 2 html javascript browser

我的网站结构如下:

<html>
  <iframe>
    <iframe>
    </iframe>
  </iframe>
<html>
Run Code Online (Sandbox Code Playgroud)

我正在编写最内在的部分iframe。现在我想确定height浏览器窗口的可用程度(menubar在可能的toolbars下开始并在可能的s之前结束)。

我有IE9并尝试过类似的东西:

window.innerHeight
Run Code Online (Sandbox Code Playgroud)

(结果未定义)和

window.parent.document.body.clientHeight 
Run Code Online (Sandbox Code Playgroud)

(不是我预期的高度)

我如何获得height?提前谢谢。

epa*_*llo 5

window.parent.document.body.clientHeight

(不是我预期的高度)。我如何获得高度?提前谢谢。

那是因为window.parent将是它上面的 iframe,而不是顶层。

你想用 window.top