您的位置:首页 > Web前端 > JavaScript

js获取页面高度赋值给div

2016-01-15 09:43 609 查看
<script type="text/javascript">
window.onload=function(){
map_width=document.body.clientWidth;//获取body宽度
map_height=document.documentElement.clientHeight;//获取页面可见高度
//alert(map_width);
//alert(map_height);
//下面两行最后的"px"必须加上,折腾了半天老是不显示添加的style,最后就是错在这了
document.getElementByIdx_x_x("maps").style.width=map_width+"px";
document.getElementByIdx_x_x("maps").style.height=map_height+"px";

}
</script>


function iframeHeight(iframeId,change) {

var ifm= document.getElementById(iframeId);

ifm.name=iframeId;

var clientHeight=document.documentElement.clientHeight;

clientHeight=clientHeight-change;

var subWeb = document.frames ? document.frames[iframeId].document : ifm.contentDocument;

if(ifm != null && subWeb != null) {

var scrollHeight=subWeb.body.scrollHeight;

if(scrollHeight>clientHeight){

ifm.height = clientHeight;
}else{

ifm.height = scrollHeight;
}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: