阿七 |
2006-04-04 14:28 |
main.htm: 3"HGEUqA y
21)~ <html> 8=lHUn9l <head> RPz!UMQSD <meta http-equiv='Content-Type' content='text/html; charset=gb2312'> Gr`MGQ, <meta name='author' content='F.R.Huang(meizz梅花雪)//www.meizz.com'> MLkL.1eGSb <title>iframe自适应加载的页面高度</title> Z?!JV_K </head> 5KL9$J9k [0mFy)6 <body> ^8o_Iz)r, <iframe src="child.htm"></iframe> I$3"|7[n </body> m;;0 Cl </html> 5Z4(J?n o(Ua",| child.htm: 8`L#1ybMO rX|y/0)F <html> .IW_DM- <head> +d6Aw}* <meta http-equiv='Content-Type' content='text/html; charset=gb2312'> O<eWq] <meta name='author' content='F.R.Huang(meizz梅花雪)//www.meizz.com'> Zq\RNZ} <title>iframe 自适应其加载的网页(多浏览器兼容)</title> 7dM6;`V^ <script language=javascript> i-:8TfI, function iframeAutoFit() 2yEO=SN,( { S|RpA'n try
A;kw}! { oUKBb&&O if(window!=parent) !TV_dKa { niBjq#bJi var a = parent.document.getElementsByTagName("IFRAME"); P*0nT for(var i=0; i<a.length; i++) //author:meizz 0]h8)EW { sw=JUfAhy if(a.contentWindow==window) "&~?Hzm { f'zU^/$rf var h = document.body.scrollHeight; Zy!)8<Cgm' if(document.all) {h += 4;} cAKoPU>U if(window.opera) {h += 1;} *Sz{DE1U a.style.height = h; U Qi^udGFD } cyHak u+ } z[|PsC3i: } ;Xd\$)n } e>vUkP y catch (ex) VM\Z<}C { !OZhfMVd alert("脚本无法跨域操作!"); ![P(B0Ct/ } U@v8H!p^i } dE}b8|</ if(document.attachEvent) window.attachEvent("onload", iframeAutoFit); q5\LdI2 else window.addEventListener('load', iframeAutoFit, false); ?k:])^G5 </script> @+CSY-g$ </head> v20I<!5w <body> o4[2`mT <div style="width: 200; height: 400; background-color: yellow"> \2<yZCn iframe 自适应其加载的网页(多浏览器兼容) hPeKQwzC0 </div> <<2b2?aS` </body> >ya- </html> |
|