//需求是,我需要通過瀏覽器內容可視化的高度來控制div的高度
boxheight(); //執行函數
function boxheight(){ //函數:獲取尺寸
//獲取瀏覽器窗口高度
var winHeight=0;
if (window.innerHeight)
winHeight = window.innerHeight;
else if ((document.body) && (document.body.clientHeight))
winHeight = document.body.clientHeight;
//通過Document對body進行檢測,獲取瀏覽器可視化高度
if (document.documentElement && document.documentElement.clientHeight)
winHeight = document.documentElement.clientHeight;
//DIV高度為瀏覽器窗口高度
document.getElementById("Odiv").style.height= winHeight +"px";
}
window.onresize=boxheight; //窗口或框架被調整大小時執行