2012-12-11 52 views
1

我想我的內容有最大化窗口的height = window.height()。當窗口未最大化時,如何獲得最大化窗口的window.height()?當我使用screen.availheight時,我的內容在Chrome中被截斷。JavaScript的大小相對於窗口大小的內容

回答

0

使用一種功能,當瀏覽器大小來調整您的內容窗...

function resize() { 
    var ht; 
      var objDiv = document.getElementById("[YOUR DIV]"); 

      if (typeof window.innerHeight != 'undefined') { 
      ht = window.innerHeight 
      } else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientHeight != 'undefined' && document.documentElement.clientHeight != 0) { 
     ht = document.documentElement.clientHeight 
    } 

      objDiv.style.height = (ht - 100) + 'px'; 
      return objDiv; 
} 

然後再調用這個地方......

onresize="resize();