Expand page height to fill the empty space when page height is less than screen height
From Code Trash
Script One
<script type="text/javascript"> function findAbsolutePosition(obj) { var curleft = curtop = 0; if (obj.offsetParent) { do { curleft += obj.offsetLeft; curtop += obj.offsetTop; } while (obj = obj.offsetParent); } return [curleft,curtop]; //returns an array } var fot = document.getElementById('footer') var pos = findAbsolutePosition(fot) var thisbot = pos[1] + fot.offsetHeight; var needheight = thisbot < window.screen.availHeight ? window.screen.availHeight - thisbot : 0 needheight -= fot.offsetHeight; window.location.hash = needheight if(needheight) { var nd = document.createElement('div') nd.style.height = needheight + 'px' nd.style.width = '100%'; document.getElementById('page').appendChild(nd) } </script>
Script Two
<script type="text/javascript"> //window.onload = function () { var thisbot = document.body.offsetHeight var ph = pageHeight(); var needheight = thisbot < ph ? ph - thisbot : 0 //needheight-= document.getElementById('footer').offsetHeight; if(needheight) { var nd = document.createElement('div') nd.style.height = needheight + 'px' nd.style.width = '100%'; document.getElementById('page').appendChild(nd) } } function pageHeight() {return window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} </script>
Reference
