3Q

解决方案 »

  1.   

    document.getElementById("ifr").width  //宽度
    document.getElementById("ifr").height
      

  2.   

    document.getElementsByTagName('iframe').clientHeight
    document.getElementsByTagName('iframe').clientWidth
      

  3.   

    不好意思,前面写错了,应该是:
    document.getElementsByTagName('iframe')[0].clientHeight
    document.getElementsByTagName('iframe')[0].clientWidth如果要根据iframe的内容动态调整iframe的高度,可以试下下面的代码:
    autoHeight();
    function autoHeight(){
    var tag=document.getElementsByTagName('iframe');
    if(tag.length){
    if(tag[0].clientHeight<tag[0].contentWindow.document.body.scrollHeight){
    tag[0].style.height=tag[0].contentWindow.document.body.scrollHeight+'px';
    }
    }
    setTimeout("autoHeight()", 10);
    }