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