var iframe = document.createElement('iframe');
        iframe.frameBorder = '0';
        iframe.id = sel;
        iframe.name = sel;
        iframe.height = '100%';
        iframe.width = '100%';
        iframe.setAttribute('onLoad', "this.height=window.frames[this.name].document.body.scrollHeight + 30");
        iframe.className = 'js-workdesk-content';        content.appendChild(iframe);
        iframe.src = url;上面就是创建一个iframe,iframe高度自适应,问题是IE6,IE7 setAttribute,不支持,有什么解决办法。
我想这样:
var div = document.createElement('div');
div.innerHTML = "<iframe>  </iframe>"
content.appendChild(div);
我觉得这样不好,不知道有什么更好的方法,求大家指点。

解决方案 »

  1.   

    iframe.onLoad=function(){...}
    这样看看。
      

  2.   

    不要用setAttribute ,这个对浏览器的兼容好像支持的不是太好
      

  3.   


    var iframe = document.createElement("iframe");
    iframe.src = "http://www.planabc.net";if (iframe.attachEvent){
        iframe.attachEvent("onload", function(){
            alert("Local iframe is now loaded.");
        });
    } else {
        iframe.onload = function(){
            alert("Local iframe is now loaded.");
        };
    }document.body.appendChild(iframe);
    摘自 http://www.xiaoxiaozi.com/2010/01/05/1683/