Difference between $(window).height() and $(document).height() function.
$(window).height() function:
Ideally $(window).height() returns the pixel less height of browser window. This is always the height of current browser window. If you resize browser this value should change.
$(document).height() function:
$(document).height() returns an unit-less pixel value of the height of the document being rendered.
In HTML if you dont declare DOCTYPE then all time HTML page returns $(window).height() and $(document).height() same value.
<html>
<head>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.10.1.js'></script>
<script type='text/javascript'>
$(document).ready(function(){
$('#winheight').text($(window).height());
$('#docheight').text($(document).height());
});
</script>
</head>
<body>
<div id="console">
$(window).height() = <span id="winheight"></span> <br/>
$(document).height() = <span id="docheight"></span>
</div>
<p>Lorem ipsum dolor sit amet</p>
</body>
</html>
Output :
$(window).height() = 750
$(document).height() = 750
Lorem ipsum dolor sit amet
After declare DOCTYPE its returns perfect value.
<!DOCTYPE HTML>
<html>
write above code here
</html>
Output :
$(window).height() = 750
$(document).height() = 750
Lorem ipsum dolor sit amet