index.htm 代码
1
<
html
>
2
<
head
>
3
<
meta
http-equiv
='Content-Type'
content
='text/html;
charset
=gb2312'
/>
4
<
meta
name
='author'
content
='F.R.Huang(meizz梅花雪)//www.meizz.com'
/>
5
<
title
>
iframe自适应加载的页面高度
</
title
>
6
</
head
>
7
8
<
body
>
9
<
div
><
iframe
src
="child.htm"
></
iframe
></
div
>
10
</
body
>
11
</
html
>
下面的说child.htm的代码
<
html
>
<
head
>
<
meta
http-equiv
='Content-Type'
content
='text/html;
charset
=gb2312'
/>
<
meta
name
='author'
content
='F.R.Huang(meizz梅花雪)//www.meizz.com'
/>
<
title
>
iframe 自适应其加载的网页(多浏览器兼容)
</
title
>
<
script
type
="text/javascript"
>
<!-- function iframeAutoFit() { try { if(window!=parent) { var a = parent.document.getElementsByTagName("IFRAME"); for(var i=0; i<a.length; i++) //author:meizz { if(a[i].contentWindow==window) { var h1=0, h2=0; a[i].parentNode.style.height = a[i].offsetHeight +"px"; a[i].style.height = "10px"; if(document.documentElement&&document.documentElement.scrollHeight) { h1=document.documentElement.scrollHeight; } if(document.body) h2=document.body.scrollHeight; var h=Math.max(h1, h2); if(document.all) {h += 4;} if(window.opera) {h += 1;} a[i].style.height = a[i].parentNode.style.height = h +"px"; } } } } catch (ex){} } if(window.attachEvent) { window.attachEvent("onload", iframeAutoFit); //window.attachEvent("onresize", iframeAutoFit); } else if(window.addEventListener) { window.addEventListener('load', iframeAutoFit, false); //window.addEventListener('resize', iframeAutoFit, false); } //-->
</
script
>
</
head
>
<
body
>
<
table
border
="1"
width
="200"
style
="height: 400px; background-color: yellow"
>
<
tr
>
<
td
>
iframe 自适应其加载的网页(多浏览器兼容,支持XHTML)
<
p
>
</
p
>
<
p
>
</
p
>
<
p
>
</
p
>
<
p
>
</
p
>
<
p
>
</
p
>
<
p
>
</
p
>
<
p
>
</
p
>
<
p
>
</
p
>
<
p
>
</
p
>
<
p
>
</
p
>
<
p
>
</
p
>
<
p
>
</
p
>
<
p
>
</
p
>
<
p
>
</
p
>
<
p
>
</
p
>
<
p
>
</
td
>
</
tr
>
</
table
>
</
body
>
</
html
>
转载于:https://www.cnblogs.com/dragonsun/archive/2007/07/06/808536.html
相关资源:各显卡算力对照表!
转载请注明原文地址: https://win8.8miu.com/read-19339.html