根据内容自动调整iframe框架高度

来源:互联网 发布:html5动画软件 编辑:程序博客网 时间:2024/04/29 21:47
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

根据内容自动调整iframe框架高度

有时为了方便使用iframe,但被潜入的页面长度不是固定的,显示滚动条不仅影响美观还对用户操作带来不便,自动调整高度可以解决这个问题。^_^

function f_frameStyleResize(targObj)
{
var targWin = targObj.parent.document.all[targObj.name];
if(targWin != null)
{
var Heightvalue = targObj.document.body.scrollHeight
if(Heightvalue < 600){Heightvalue = 600} //不小于600
targWin.style.pixelHeight = Heightvalue;
}
}
function f_iframeResize()
{
bLoadComplete = true;
f_frameStyleResize(self);
}

var bLoadComplete = false;
window.onload = f_iframeResize;

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>