我写的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>
解决 1无用
悬赏问题
- ¥15 如何在scanpy上做差异基因和通路富集?
- ¥20 关于#硬件工程#的问题,请各位专家解答!
- ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
- ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
- ¥30 截图中的mathematics程序转换成matlab
- ¥15 动力学代码报错,维度不匹配
- ¥15 Power query添加列问题
- ¥50 Kubernetes&Fission&Eleasticsearch
- ¥15 報錯:Person is not mapped,如何解決?
- ¥15 c++头文件不能识别CDialog