最终结果,刚找到的,兼容所有浏览器(1)在 IE4、IE5 和 没有声明 DOCTYPE 的 IE6 中,视口的这一信息保存在“body”元素中,可以用 document.body.offsetWidth / offsetHeight 获取,(2)在声明了DOCTYPE 的 IE6 中 ,视口的这一信息保存在 document.documentElement 中,可以用 document.documentElement.clientWidth / clientHeight 获取。(3)除了 IE 以外的所有浏览器都将此信息保存在 window 对象中,可以用 window.innerWidth / innerHeight 获取。<script language="javascript" type="text/javascript">
function hh()
{
if(window.innerHeight){
h = window.innerHeight;//Mozilla
}else if(document.documentElement.clientHeight){
h = document.documentElement.clientHeight;//IE6
}else{
h = document.body.clientHeight;//IE5.x
}
mainTable.style.height=h;
}
window.onresize=hh;
window.onload=hh;
</script>
function hh()
{
if(window.innerHeight){
h = window.innerHeight;//Mozilla
}else if(document.documentElement.clientHeight){
h = document.documentElement.clientHeight;//IE6
}else{
h = document.body.clientHeight;//IE5.x
}
mainTable.style.height=h;
}
window.onresize=hh;
window.onload=hh;
</script>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货