//让Iframe自动适应高度
function SetWinHeight(obj)
{
var win=obj;
if (document.getElementById)
{
if (win && !window.opera)
{
if (win.contentDocument && win.contentDocument.body.offsetHeight)
{
if(win.contentDocument.body.offsetHeight<420){
win.height = 420;//设置最小高度
}else{
win.height = win.contentDocument.body.offsetHeight;
}
}
else if(win.Document && win.Document.body.scrollHeight)
win.height = win.Document.body.scrollHeight;
}
}
}
html标签:
<iframe name="dtl" id="dtl" src="" onload="Javascript:SetWinHeight(this)" height="100%" width="100%" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="auto"></iframe>
onload="Javascript:SetWinHeight(this)"一定要有