与主网页侧边栏滚动的iframe [英] Scrolling iframe with main page side bar

查看:608
本文介绍了与主网页侧边栏滚动的iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是非常棘手的情况我已经尝试了许多东西,但不能弄明白。我有以下的iframe:

Here is very tricky situation i have tried many things but cant figure it out. I have following iframe:

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

来源是通过jQuery的进入了这一点。问题是,当输入源它是两个在高度和宽度大。所以,我看到两个滚动条。反正是有该iframe的数据将与主网页滚动条移动。而不是增加两个不同的滚动条。
这里就是我现在看到的图像:

Source is entered through jquery to this. Problem is when source is entered it is two big in height and width. So i see two scroll bars. Is there anyway that iframe data will move with main page scrollbar. Rather than adding two different scrollbars. Here is an image of what i am seeing now:

推荐答案

您需要调整它的内容已经排满了,这可以通过使用Javascript完成。

You need to resize it after the content have been filled, and this can done by using 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的滚动条。

Other solution is to add height and width to a persent value, like 100% to get all the width/height of your window, and hide the scroll bars of iframe.

这篇关于与主网页侧边栏滚动的iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆