zoukankan      html  css  js  c++  java
  • JS_同域下的ifream自适应高度和设置注意等

    NO.1: 创建一个无边框的ifream.

      <iframe src="ifream.html" frameborder="0" width="300" height="150"  id="myframe1">

    NO.2:设置ifream的背景.

      在ifream.html里面写样式设置body的背景.

    NO.3:使ifream的高度自适应.

      在ifream.html内定义一个高度为250的DIV.

        .main{background:#F00;height:200px}

        <div id="main" class="main">1</div>

      自己的页面内JS代码:

    function addEvent(id,en,fu){
        if(id.addEventListener){
            id.addEventListener(en,fu,false);
            }else if(id.attachEvent){
            id.attachEvent("on"+en, fu);
            }
        }
    var if1 = document.getElementById("myframe1");
    if(if1.Document){
        addEvent(if1,"load",function(){
            if1.height = if1.Document.documentElement.scrollHeight;
            });
        }else if(if1.contentDocument){
        addEvent(if1,"load",function(){
            if1.height = if1.contentDocument.documentElement.scrollHeight;
            });
        }
  • 相关阅读:
    十二月31日
    十二月31号
    10,28
    10,27
    十月26
    十月22
    十月21
    十月二十
    十月16
    0227 数据库的知识
  • 原文地址:https://www.cnblogs.com/somesayss/p/2633114.html
Copyright © 2011-2022 走看看