|
function SetWinHeight(obj)
{
var win=obj;
if (document.getElementById)
{
if (win && !window.opera)
{
if (win.contentDocument && win.contentDocument.body.offsetHeight)
win.height = win.contentDocument.body.offsetHeight;
else if(win.Document && win.Document.body.scrollHeight)
win.height = win.Document.body.scrollHeight;
}
}
}
最后,加入iframe,不能丟掉onload屬性,當然了,id也必須也函數中的win匹配
程序代碼
復制代碼 代碼如下:
<iframe width=”778″ align=”center” height=”200″ id=”win” name=”win” onload=”Javascript:SetWinHeight(this)” frameborder=”0″ scrolling=”no”></iframe>
JavaScript技術:js實現iframe動態調整高度的代碼,轉載需保留來源!
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。