`
cjnetwork
  • 浏览: 177307 次
  • 性别: Icon_minigender_1
  • 来自: 重庆
社区版块
存档分类
最新评论

iframe自适应高度

 
阅读更多
<script>
function dyniframesize(down) { 
var pTar = null; 
if (document.getElementById){ 
pTar = document.getElementById(down); 
} 
else{ 
eval('pTar = ' + down + ';'); 
} 
if (pTar && !window.opera){ 
//begin resizing iframe 
pTar.style.display="block" 
if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){ 
//ns6 syntax 
//alert(pTar.contentDocument.body.scrollHeight + '      ' + pTar.contentDocument.body.offsetHeight);
//pTar.height = 5000; 
pTar.width = pTar.contentDocument.body.scrollWidth;
$('#win').height(pTar.contentDocument.body.scrollHeight + 100);
//alert(pTar.height);
} 
else if (pTar.Document && pTar.Document.body.scrollHeight){ 
//ie5+ syntax 
pTar.height = pTar.Document.body.scrollHeight; 
pTar.width = pTar.Document.body.scrollWidth; 
} 
} 
}


function kk(){
	var node = $('#win').contents().find('.Comment');
	if(node.size() > 0){
		dyniframesize('win');
	}else{
		setTimeout('kk()',500);
	}
}
</script>
<iframe onload="kk()" id="win" name="win" src="<yuce type="paraReplace" paras="^dynamicServer"/>commentAction!queryByClient?articleId=<yuce type="paraReplace" paras="$id"/>" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" width="100%"></iframe>


<SCRIPT language=javascript type=text/javascript>

function autoResize()
{
 try
 {
  document.all["bodyFrame"].style.height=bodyFrame.document.body.scrollHeight
 }
 catch(e){}
}

</SCRIPT>
<iframe src="http://www.baidu.cn" name="bodyFrame" scrolling="no" src="" width="100%" height=100% style="height:expression(1); aho:expression(autoResize())" frameborder="0"></iframe>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics