阿七 |
2006-04-04 14:28 |
main.htm: ]<27Sw&yaG ;OOj[%. <html> |XKOXa3. <head> +
a-wv <meta http-equiv='Content-Type' content='text/html; charset=gb2312'> N;-/w ip <meta name='author' content='F.R.Huang(meizz梅花雪)//www.meizz.com'> 3ty4D 2y <title>iframe自适应加载的页面高度</title> I&L.;~ </head> rO/a,vV fyM3UA\U <body> )@}A
r <iframe src="child.htm"></iframe> ?gLR<d_ </body> Wrmgu}q </html> "\}b!gl$8 a9[mZVMgUK child.htm: _
XE;-weE >s&XX,
w <html> A -Mj|V <head> r"R(}`<, <meta http-equiv='Content-Type' content='text/html; charset=gb2312'> s(t eQ\ <meta name='author' content='F.R.Huang(meizz梅花雪)//www.meizz.com'> NX?}{'f <title>iframe 自适应其加载的网页(多浏览器兼容)</title> wHx}U M" <script language=javascript> YWEYHr;%^? function iframeAutoFit() o`idg[l. { P{?;T5ap6 try 'e F% { _ w/_(k if(window!=parent) w4UD/zO { Q| ?'(J+ var a = parent.document.getElementsByTagName("IFRAME"); TN5>" ??" for(var i=0; i<a.length; i++) //author:meizz eNtf#Rqym { rWA6XDM7 if(a.contentWindow==window) 80C(H!^ { V\0E=M*P var h = document.body.scrollHeight; 8) HBh7/ if(document.all) {h += 4;} FQ`(b3.
if(window.opera) {h += 1;} ?ty>}.c t a.style.height = h; yNBv-oe5 } e!GZSk
} 9UV9
h_.x } !}_b| } V43TO catch (ex) S`0NPGn;@[ { sf$o(^P9\A alert("脚本无法跨域操作!"); / 2xSNalC } A{N\) } <YH=3[ if(document.attachEvent) window.attachEvent("onload", iframeAutoFit); \|.7-X else window.addEventListener('load', iframeAutoFit, false); O#)jr-vXdV </script> ^XG*z?Tt </head> #Y2i*:< <body> 4jX3lq| <div style="width: 200; height: 400; background-color: yellow"> 3#c3IZ-; iframe 自适应其加载的网页(多浏览器兼容) eklgLU-+fW </div> &l m# </body> 2o4^ </html> |
|