iframe高度自动调整的问题
parent.document.getElementById( 'mainFrame ').style.height=document.body.scrollHeight+ "px ";
这样写只能在IE下有用,FF下的该怎么写
------解决方案--------------------梅子写过一个,你去找找
------解决方案-------------------- <iframe id= "contentframe " scrolling= "no " onload= "javascript:{dyniframesize ( 'contentframe ');} " > </iframe>
在 <head> 中加入:
<script language= "Javascript ">
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf( "Firefox ")).split( "/ ")[1]
//extra height in px to add to iframe in FireFox 1.0+ browsers
var FFextraHeight=getFFVersion> =0.1? 16 : 0
function dyniframesize(iframename)
{
var pTar = null;
if (document.getElementById)
{
pTar = document.getElementById(iframename);
}
else
{
eval( 'pTar = ' + iframename + '; ');
}
var urlstr=location.href.split( ".aspx ")[1];
if(urlstr.lenght> 0)
{
pTar.src= "blogframe/blogcontent.aspx "+urlstr;
}
if (pTar && !window.opera)
{
//begin resizing iframe
pTar.style.display= "block "
if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight)
{
//ns6 syntax
pTar.height = pTar.contentDocument.body.offsetHeight+FFextraHeight;
}
else if (pTar.Document && pTar.Document.body.scrollHeight)
{
//ie5+ syntax
pTar.height = pTar.Document.body.scrollHeight;
}
}
}
</script>