如何在加载iframe后隐藏父垂直滚动条? [英] How to hide the parent vertical scrollbar after an iframe is loaded?

查看:133
本文介绍了如何在加载iframe后隐藏父垂直滚动条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我附上了演示问题的示例代码。我在Firefox 3.5.7中检查这个。问题是父HTML有一个滚动条,它加载一个全屏的iframe(高度:100%,宽度:100%),我希望在加载iframe后删除父滚动条。

I have attached the sample code which demonstrates the problem. I am checking this in Firefox 3.5.7. The problem is the parent HTML has a scrollbar, and it loads an iframe which is fullscreen (height: 100%, width: 100%), I want the parent scrollbar to be removed after the iframe is loaded.

1)这可能吗?
2)当我们给出高度:100%;宽度:100%为什么它只占据视野区域?但不是
完整的父母占用区域?

1) Is this possible to do? 2) When we give height: 100%; width: 100% why does it occupy only the view area? But not the full parent occupied area?

This is Main.html
        <Html>
    <head>
        <script type="text/javascript" src="client.js"></script>
        <title>
            I am a client
        </title>    
    </head>
    <body bgcolor="#000000">
        You can see the iframe below...
        You can see the iframe below...
        You can see the iframe below...<br><br>
        <br><br><br><br><br><br>
        <br><br><br><br><br><br>
        <br><br><br><br><br><br>
        <br><br><br><br><br><br>
        <br><br><br><br><br><br><br>
        <br><br><br><br><br><br>
        You can see the iframe below...
        <br>

        <iframe name="clientframe" id = "clientframe" src = "app.html" style="position:absolute;top:0px;left:0px;width:100%;height:100%;z-index:999;background:#ff0000" 
        onload = "sendparams();" frameborder="no">
        </iframe>    
    </body>
    </html>

This is app.html:
<HTML>
<HEAD>
    <title> 
        I am an Application
    </title>
</HEAD>
<BODY>
    <h3>This is an application</h3>
    <br>
    You name <input type="textbox"> <br>
    Password <input type="password"><br>
    <br>
    <br>
    <input type="button" value ="Let me in">
</BODY>

</HTML>

注意:打开Main.html,它会在iframe中加载app.html。您可以注意到,在加载iframe后会出现一个滚动条,而iframe的红色背景并不会完全填满整个父级。

NOTE: Open the Main.html, it will load the app.html in a iframe. You can notice that after iframe is loaded a scroll bar appears, and the red background for the iframe does not completely fill the entire parent.

推荐答案

加载iframe时隐藏父窗口滚动条

Hide the Parent window scroll bar when iframe is loaded

将此脚本放在Main.html的顶部

put this script at top of the Main.html

<script type="text/javascript">
 function sendparams() {
 document.body.style.overflow = "hidden";
 }
</script>

这篇关于如何在加载iframe后隐藏父垂直滚动条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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