zoukankan      html  css  js  c++  java
  • js控制iframe自适应高

    ===========================index.html====================

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head>
    <script type="text/javascript" language="javascript">
    function iFrameHeight() {
        var ifm= document.getElementById("iframepage");
        var subWeb = document.frames ? document.frames["iframepage"].document : ifm.contentDocument;
        if(ifm != null && subWeb != null) {
            ifm.height = subWeb.body.scrollHeight;
        }
    }
    </script>
    <body>
    aaaaaaaaaaaaaaa
    <iframe onLoad="iFrameHeight()" src="iframe.html" id="iframepage"  frameBorder="1" scrolling="no" width="100%" >
    </iframe>
    bbbbbbbbbbbbbb
    </body>
    </html>

    ===========================iframe.html====================

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head>
    <body style="padding:0; margin:0;">
    1111111111
    <div style="border:#00FFFF thin solid; 300px; height:300px; background:#CCCC99"></div>
    2222222222
    </body>
    </html>
  • 相关阅读:
    windows常用命令行总结
    express安装
    MySQL去除外键关联关系
    c#实体转化
    C#之Clone
    mysql 将null转代为0(转)
    Mysql显示行号
    mysql存储过程游标加计划任务事件调度器
    mysql临时表
    Git学习笔记
  • 原文地址:https://www.cnblogs.com/fonyer/p/2814368.html
Copyright © 2011-2022 走看看