.body.scrollHeight在Firefox中不起作用 [英] .body.scrollHeight doesn't work in Firefox

查看:44
本文介绍了.body.scrollHeight在Firefox中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.body.scrollHeight 在Firefox中不起作用.

.body.scrollHeight does not work in Firefox.

请参阅: http://jsfiddle.net/gjrowe/X63KR/

要使用的正确语法是什么?

What is the correct syntax to use instead?

推荐答案

此问题与......上的线程具有相同的根本问题.

This question has the same root problem as the thread at... Dynamically define iframe height based on window size (NOT CONTENT)

了解该线程的问题将为此提供解决方案.

Understanding the issue at that thread will give the solution to this.

基本上,而不是使用 .body.scrollHeight ,而是添加此代码...

Basically, instead of using .body.scrollHeight, add this code...

function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

答案来自: http://james.padolsey.com/javascript/get-document-height-cross-browser/

这篇关于.body.scrollHeight在Firefox中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆