0

我需要在 Internet Explorer 中获取窗口的宽度和高度

最初我使用了一个很好的简单语句 var height = HtmlPage.Window.Eval("innerHeight").ToString();

但是我后来发现这在 IE 8 中不起作用

似乎有很多不同的方法来获取窗口的宽度和高度,我不确定哪种方法最好,但这里提到了下面的方法 Get the window height

文档 = 文档;var theHeight = Math.max( doc.body.scrollHeight, doc.documentElement.scrollHeight, doc.body.offsetHeight, doc.documentElement.offsetHeight, doc.body.clientHeight, doc.documentElement.clientHeight );

我的问题是如何将其放入 Window.Eval 以获得高度?

语法需要是什么?

如果有更好、更可靠的获取窗口宽度和高度的方法,请告诉我,但它需要适用于不同的浏览器

保罗

4

1 回答 1

0

未经测试。只是调整你的代码......

HtmlPage.Window.Eval("Math.max( document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight )").ToString();

于 2013-10-04T03:00:24.993 回答