JS实现iframe动态自适应高度、去滚动条

//兼容Chrome、FireFox、IE、Opera各版本浏览器,setInterval性能影响完全不需要担心

<script>
    function SetCwinHeight(){
        var cwin=document.getElementById('frame');
        if (document.getElementById){
            if (cwin && !window.opera){
                if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight)
                cwin.height = cwin.contentDocument.body.offsetHeight + 20; //FF NS
                else if(cwin.Document && cwin.Document.body.scrollHeight)
                cwin.height = cwin.Document.body.scrollHeight + 10;//IE
            }else{
                if(cwin.contentWindow.document && cwin.contentWindow.document.body.scrollHeight)
                cwin.height = cwin.contentWindow.document.body.scrollHeight;//Opera
            }
        }
    }
    window.setInterval("SetCwinHeight()",200);
</script>
<iframe id='frame' name='frame' src="frame.html" frameborder="0" width="100%" scrolling="no" onload="SetCwinHeight()"></iframe>