ldlok2002 2019-06-12 14:52 采纳率: 0%
浏览 1602

html <ifrmae>中设置点击隐藏左边菜单栏,如何使右边内容区域全屏显示?

我写的js很简单,实现了点击隐藏左边菜单功能,但右边内容区域总是不能全屏显示,有一块空白仍是调用前的div,这种隐藏有何用?求高手指点如何实现内容里面的表格也能自动全屏。就像最后两张图片中的效果一样,谢谢了!图片说明图片说明图片说明图片说明图片说明

  • 写回答

2条回答 默认 最新

  • 听楼一夜雨 2019-06-12 16:50
    关注
    <iframe id="iframe" src="txt.html" width="100%" frameborder="0" scrolling="no" allowtransparency="true" width="100%" height="50%" frameborder="0"></iframe>
    <script>
    window.onload=function(){
          function calcPageHeight(doc) {
              var cHeight = Math.max(doc.body.clientHeight, doc.documentElement.clientHeight,doc.body.offsetHeight)
              var sHeight = Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight,doc.body.offsetHeight)
              var height  = Math.max(cHeight, sHeight);
              return height
          }
          //根据ID获取iframe对象
          var ifr = document.getElementById('mainFrame')
          ifr.onload = function() {
    
              ifr.style.height='0px';
              var iDoc = ifr.contentDocument || ifr.document
              var height = calcPageHeight(iDoc)
              console.log(height)
              if(height < 850){
                height = 850;
              }
              ifr.style.height = height + 'px'
          }
    
    }
    </script>
    

    txt.html

    <table width="100%" cellspacing="0">
              <thead>
                <tr>
                  <th width="10%">aa</th>
                  <th width="10%">bb</th>
                  <th width="10%" align="left">cc</th>
                  <th width="10%" align="left">d</th>
                  .
                  .
                  .
                  <th width="10%" align="left">d</th>
                </tr>
              </thead>  
      </table> 
    
    
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记