首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

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

2012-10-14 
处理iframe自适应高度的js方法js代码//taolm 用来处理iframe自适应高度的js方法 //down 参数为iframe的idf

处理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% />

热点排行