iframe只适应大小。ps:在ie和ff通过测试

来源:互联网 发布:淘宝试衣间软件 编辑:程序博客网 时间:2024/06/07 05:42

<script type="text/javascript">
function reinitIframe(){
//高度适应
var iframe = document.getElementById("personiframe");
try{
var bHeight = iframe.contentWindow.document.body.scrollHeight;
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight);
iframe.height =  height;
}catch (ex){}
//宽度适应
try{
var fwidth = iframe.contentWindow.document.body.scrollWidth;
var dwidth = iframe.contentWindow.document.documentElement.scrollWidth;
var ffwidth = Math.max(fwidth, dwidth);
iframe.width =  ffwidth;
}catch (ex){}
}
window.setInterval("reinitIframe()", 200);
</script>

原创粉丝点击