`
zhzhiqun2005
  • 浏览: 220434 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

处理iframe自适应高度的js方法

阅读更多
js代码

//taolm 用来处理iframe自适应高度的js方法 
//down 参数为iframe的id
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 
			pTar.height = pTar.contentDocument.body.offsetHeight +20; 
			pTar.width = pTar.contentDocument.body.scrollWidth+20; 
		} 
		else if (pTar.Document && pTar.Document.body.scrollHeight){ 
			//ie5+ syntax 
			pTar.height = pTar.Document.body.scrollHeight; 
			pTar.width = pTar.Document.body.scrollWidth; 
		} 
	} 
}
 



iframe应用
	       <iframe src="" name="glxxmain" id="glxxmain" scrolling="No" noresize="noresize" onload="javascript:dyniframesize('glxxmain');" frameborder=0 width=100% />
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics