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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM