使用javascript实现Iframe自适应高度
前端之家收集整理的这篇文章主要介绍了
使用javascript实现Iframe自适应高度,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_403_0@方法一:
@H_
403_0@<div class="codetitle">
<a style="CURSOR: pointer" data="69042" class="copybut" id="copybut69042" onclick="doCopy('code69042')"> 代码如下: <div class="codebody" id="code69042">
$(window.parent.document).find("#ContentIframe").load(function() {
var main = $(window.parent.document).find("#ContentIframe");
var thisheight = $(document).height();
if (thisheight < 800)
thisheight = 800;
main.height(thisheight);
});
@H_
403_0@ var main = $(window.parent.document).find("#ContentIframe");
var thisheight = $("body").height();
if (thisheight < 800) { thisheight = 800; }
main.height(thisheight+50);
setTimeout(setMainHeight,2000);
}