189 8069 5689

HTML的<iframe>标签如何使用

这篇文章主要讲解了“HTML的

HTML

3.内容宽度变化的iframe高度自适应:

functioniframeAutoFit(iframeObj){

setTimeout(function(){if(!iframeObj)return;iframeObj.height=(iframeObj.Document?iframeObj.Document.body.scrollHeight:iframeObj.contentDocument.body.offsetHeight);},200)

}

4.打开调试运行窗口可以看到运行:

functionreinitIframe(){

variframe=document.getElementById("test");

try{

varbHeight=iframe.contentWindow.document.body.scrollHeight;

vardHeight=iframe.contentWindow.document.documentElement.scrollHeight;

varheight=Math.max(bHeight,dHeight);

iframe.height=height;

console.log(height);

}catch(ex){}

}

window.setInterval("reinitIframe()",200);

提示栏:

提示:您可以把需要的文本放置在之间,这样就可以应对不支持