【问题标题】:Iframe not resizing IE10iframe 不调整 IE10 的大小
【发布时间】:2013-07-09 20:34:26
【问题描述】:

我发现这种流行的 javascript 在 IE10 中不起作用。我没有创建它,但正在维护一个实现它的站点。想知道有没有其他人遇到过。似乎 Document.getElmsntById('frame').onload 事件不起作用,但 window.resize 事件起作用。初始帧加载的含义它不会重新调整大小,但是当我对窗口执行任何操作时它会。它只是在 iframe 中打开的 pdf。在 Win 7 和 8 机器上,除 IE10 之外的所有浏览器似乎都很好。

<script type="text/javascript">
    function resizeIframe() {
    var height = document.documentElement.clientHeight;
    height -= document.getElementById('frame').offsetTop;
    height -= 250;         
    document.getElementById('frame').style.height = height +"px"; 
    };
    document.getElementById('frame').onload = resizeIframe;
    window.onresize = resizeIframe;
</script>

【问题讨论】:

    标签: javascript iframe internet-explorer-10


    【解决方案1】:

    对不起,如果我的问题太含糊了。我用谷歌搜索了这个,发现了类似的情况,但和我的不完全一样。我提醒了高度变量并检查了一个条件,就像我提到的浏览器只会在调整大小时运行该功能,所有其他浏览器都很好。我不知道为什么,但我决定在 onload 事件的调用中添加空括号并且它起作用了。

    document.getElementById('frame').onload = resizeIframe(); 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-04
      • 2013-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多