首页 > 技术文章 > js iframe onload &line-height浏览器兼容问题

lucybloguniquecom 2015-11-24 16:09 原文

1、IE iframe onload事件

在IE下给iframe添加onload事件经常无效,因为在IE下它最多只能被激活一次,而且无论你有多少个iframe,被激活的也只能是最后一个的。可以用下面的方法加载,保险起见可在定义iframe 时添加onload事件。

function AddOnloadEvent(){

            var frame = document.getElementById('iframe');

            if (iframe.attachEvent){

                frame.attachEvent('onload',funLoad);//border加载事件

            }

            else{

                iframe.onload = funLoad;

            }

        }

function funLoad() {

……

}

<iframe scrolling="auto" frameborder="0" id="iframe" src="" onload="funLoad()"></iframe>

 2、IE浏览器中设置行高,有时不能起到设置高度的作用,需要加上height:39px,最好加上overflow: hidden,(注意:”overflow: hidden;“,如果你在容器(DIV)里有其他绝对定位的层时,别用!); 而其他浏览器无需

推荐阅读