Maison  >  Article  >  interface Web  >  iframe 自适应高度[在IE6 IE7 FF下测试通过]_javascript技巧

iframe 自适应高度[在IE6 IE7 FF下测试通过]_javascript技巧

WBOY
WBOYoriginal
2016-05-16 18:54:17784parcourir

第一种方法:

复制代码 代码如下:





第二种方法:
js code:
复制代码 代码如下:

//iframe自适应高度[在IE6 IE7下测试通过]
function reSetIframe(){
var iframe = document.getElementById("iframeId");
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){}
}

html:
复制代码 代码如下:


Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn