Advertisement
amereservant

Auto resize div 100% javascript

Aug 9th, 2011
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2. function resize(elHeight){
  3.     if(document.getElementById) {
  4.         var windowheight = 0;
  5.         var targetEl = document.getElementById('content');
  6.         var curEl = document.getElementsByTagName('body')[0];
  7.         var curHeight = curEl.offsetHeight;
  8.         targetEl.style.height = (curHeight > elHeight ? curHeight:elHeight)+'px';
  9.     }
  10. }
  11. var elHeight = document.getElementById('content').offsetHeight;
  12. window.onload = function(){resize(elHeight);}
  13. window.onresize = function(){resize(elHeight);}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement