正在躊躇的時(shí)候發(fā)現(xiàn)下面的這段代碼,終于得意解決。苦于對(duì)js沒有足夠的熟悉,代碼中的具體方法參數(shù)還得繼續(xù)學(xué)習(xí),感謝提供代碼的朋友。
function SetCwinHeight()
{
var cwin=document.getElementById("cwin");
if (document.getElementById)
{
if (cwin && !window.opera)
{
if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight)
cwin.height = cwin.contentDocument.body.offsetHeight;
else if(cwin.Document && cwin.Document.body.scrollHeight)
cwin.height = cwin.Document.body.scrollHeight;
}
}
}
<iframe width="778" align="center" height="200" id="cwin" name="cwin" onload="Javascript:SetCwinHeight(this)" frameborder="0" scrolling="no"></iframe>
function SetCwinHeight(obj)
{
??var cwin=obj;
??if (document.getElementById)
??{
????if (cwin && !window.opera)
????{
??????if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight)
????????cwin.height = cwin.contentDocument.body.offsetHeight;
??????else if(cwin.Document && cwin.Document.body.scrollHeight)
????????cwin.height = cwin.Document.body.scrollHeight;
????}
??}
}
引用時(shí)
onload="javascript:SetCwinHeight(this)"
posted on 2006-04-27 15:50
黑咖啡 閱讀(39315)
評(píng)論(13) 編輯 收藏 所屬分類:
Coding Life