【问题标题】:Scrolling iframe with main page side bar使用主页侧栏滚动 iframe
【发布时间】:2012-02-01 21:54:56
【问题描述】:

这是一个非常棘手的情况,我尝试了很多东西但无法弄清楚。我有以下 iframe:

<div id="content"> <iframe id="iF" name="if" marginwidth="0" marginheight="0" frameborder="0" src=""></iframe>
</div>

源是通过jquery输入到这个的。问题是当输入源时,它的高度和宽度是两个大。所以我看到两个滚动条。无论如何,iframe 数据会随着主页滚动条移动。而不是添加两个不同的滚动条。 这是我现在看到的图像:

【问题讨论】:

    标签: asp.net css


    【解决方案1】:

    内容填充后需要调整大小,可以使用Javascript来完成。

    <script type="text/javascript">
        function iframeLoaded()
        {
            var iFrameID = document.getElementById('idIframe');
    
            if(iFrameID)
            {
                // here you can meke the height, I delete it first, then I make it again
                iFrameID.height = "";
                iFrameID.height = iFrameID.contentWindow.document.body.scrollHeight + "px";
            }   
        }
    </script>   
    
    
    <iframe id="idIframe" onload="iframeLoaded()" ...
    

    其他解决方案是将高度和宽度添加到 persent 值,例如 100% 以获取窗口的所有宽度/高度,并隐藏 iframe 的滚动条。

    【讨论】:

      猜你喜欢
      • 2012-12-29
      • 2019-06-30
      • 2016-06-09
      • 2021-12-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-19
      • 1970-01-01
      • 2022-10-25
      相关资源
      最近更新 更多