admin管理员组文章数量:1289384
I am trying to get access to the height of the entire page (including scrolling). In chrome, document.body.scrollHeight does this. In firefox, this doesn't work... what is the equivalent in firefox?
I am trying to get access to the height of the entire page (including scrolling). In chrome, document.body.scrollHeight does this. In firefox, this doesn't work... what is the equivalent in firefox?
Share Improve this question asked Jan 13, 2012 at 21:16 derusederuse 2,8817 gold badges42 silver badges61 bronze badges 2- 1 With a scrollbar, it doesnt. jQuery takes care of it thought. – deruse Commented Jan 13, 2012 at 21:25
- did you find a solution for FF ? – Eugene Gluhotorenko Commented Jun 25, 2012 at 10:32
3 Answers
Reset to default 1definitely start using jquery, accessing $(document).height() will do all the browser checks for you.
http://api.jquery./height/
You can use jquery to do this without browser problem.
User jQuery $(document).height()
and $(document).scrollTop()
functions
<script type="text/javascript">
var scnWid,scnHei;
if (self.innerHeight) // all except Explorer
{
scnWid = self.innerWidth;
scnHei = self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientHeight)
// Explorer 6 Strict Mode
{
scnWid = document.documentElement.clientWidth;
scnHei = document.documentElement.clientHeight;
}
else if (document.body) // other Explorers
{
scnWid = document.body.clientWidth;
scnHei = document.body.clientHeight;
}
</script>
本文标签: javascriptdocumentbodyscrollHeight yielding two different results in firefoxchromeStack Overflow
版权声明:本文标题:javascript - document.body.scrollHeight yielding two different results in firefoxchrome - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741446560a2379237.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论