Document.body.scrollHeight gives two different results in firefox / chrome

I am trying to access the height of the whole page (including scrolling). In chrome, document.body.scrollHeight does this. In firefox, this does not work ... what is equivalent in firefox?

+5
source share
3 answers

You can use jquery for this without a browser problem.

JQuery user functions $(document).height()and$(document).scrollTop()

+2
source

definitely start using jquery, gaining access to $ (document) .height () will do all the browser checks for you.

http://api.jquery.com/height/

+1
source
<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>
+1
source

All Articles