读书人

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

发布时间: 2012-10-14 14:55:07 作者: rapoo

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

//taolm 用来处理iframe自适应高度的js方法 //down 参数为iframe的idfunction 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% />

读书人网 >JavaScript

热点推荐