js获取页面高度赋值给div

<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;
          }
         
      }   
      
} 

 

转载于:https://www.cnblogs.com/jinzhiming/p/5132394.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值