zoukankan      html  css  js  c++  java
  • 动态改变iframe的高度

    网上找了很久,发现都不能实现缩小iframe高度,自己修改了一下,发现原来是js添加了height以后,再取时就都是这个值了。所以只要做如下的修改就行了,IE6+,FF都有用。

     1 function changeHeight(obj) {
     2     var cwin=document.getElementById("frameId");
     3     cwin.removeAttribute('height');
     4     var iframeHeight = 0;
     5     if (document.getElementById) {
     6         if (cwin && !window.opera) {
     7             if (cwin.contentDocument && cwin.contentDocument.body.scrollHeight)
     8                 iframeHeight = cwin.contentDocument.body.scrollHeight + 10; //FF NS
     9             else if(cwin.Document && cwin.Document.body.scrollHeight)
    10                 iframeHeight = cwin.Document.body.scrollHeight + 10;//IE
    11         } else {
    12             if(cwin.contentWindow.document && cwin.contentWindow.document.body.scrollHeight)
    13                 iframeHeight = cwin.contentWindow.document.body.scrollHeight + 10;//Opera
    14         }
    15     }     
    16     document.getElementById('frameId').height=iframeHeight;

    17 } 

  • 相关阅读:
    向量空间模型 词袋模型
    python 小点
    python list的append()和extend()方法
    numpy 数组运算
    内置函数和numpy中的min(),max()函数
    python index()函数
    Python支持的正则表达式元字符和语法
    Python多线程
    查看linux机器配置&内核版本
    Shell获取文件的文件名和扩展名的例子
  • 原文地址:https://www.cnblogs.com/zhuyoufeng/p/2196140.html
Copyright © 2011-2022 走看看