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
Add a ment  | 

3 Answers 3

Reset to default 1

definitely 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