概述
main.htm 主页面
< html >
< head >
< meta http-equiv ='Content-Type' content ='text/html; charset =gb2312' />
< title > iframe自适应加载的页面高度 </ title >
</ head >
< body >
< iframe src ="child.htm" ></ iframe >
</ body >
</ html >
frame.htm 内嵌框架页
< html >
< head >
< meta http-equiv ='Content-Type' content ='text/html; charset =gb2312' />
< title > iframe 自适应其加载的网页(多浏览器兼容) </ title >
< script type ="text/javascript" >
<!--
function iframeAutoFit()
{
var ex;
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, h3=0, h4=0;
if(document.documentElement&&document.documentElement.scrollHeight)
{
h1 = document.documentElement.scrollHeight;
h3 = document.documentElement.scrollWidth;
}
if(document.body) h2=document.body.scrollHeight;h4=document.body.scrollWidth;
var h=Math.max(h1, h2);
var h0=Math.max(h3,h4);
a[i].style.height = h +"px";
a[i].style.width = h0 + "px";
}
}
}
}
catch (ex){}
}
if(document.attachEvent)
{
window.attachEvent("onload", iframeAutoFit);
window.attachEvent("onresize", iframeAutoFit);
}
else
{
window.addEventListener('load', iframeAutoFit, false);
window.addEventListener('resize', iframeAutoFit, false);
}
//-->
</ script >
</ head >
< body style ="overflow:hidden;border:0px" >
< table border ="1" width ="200" style ="height: 200px;width:300px;" >
< tr >
< td > iframe 自适应其加载的网页(多浏览器兼容,支持XHTML) </ td >
</ tr >
</ table >
</ body >
</ html >
< html >
< head >
< meta http-equiv ='Content-Type' content ='text/html; charset =gb2312' />
< title > iframe自适应加载的页面高度 </ title >
</ head >
< body >
< iframe src ="child.htm" ></ iframe >
</ body >
</ html >
frame.htm 内嵌框架页
< html >
< head >
< meta http-equiv ='Content-Type' content ='text/html; charset =gb2312' />
< title > iframe 自适应其加载的网页(多浏览器兼容) </ title >
< script type ="text/javascript" >
<!--
function iframeAutoFit()
{
var ex;
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, h3=0, h4=0;
if(document.documentElement&&document.documentElement.scrollHeight)
{
h1 = document.documentElement.scrollHeight;
h3 = document.documentElement.scrollWidth;
}
if(document.body) h2=document.body.scrollHeight;h4=document.body.scrollWidth;
var h=Math.max(h1, h2);
var h0=Math.max(h3,h4);
a[i].style.height = h +"px";
a[i].style.width = h0 + "px";
}
}
}
}
catch (ex){}
}
if(document.attachEvent)
{
window.attachEvent("onload", iframeAutoFit);
window.attachEvent("onresize", iframeAutoFit);
}
else
{
window.addEventListener('load', iframeAutoFit, false);
window.addEventListener('resize', iframeAutoFit, false);
}
//-->
</ script >
</ head >
< body style ="overflow:hidden;border:0px" >
< table border ="1" width ="200" style ="height: 200px;width:300px;" >
< tr >
< td > iframe 自适应其加载的网页(多浏览器兼容,支持XHTML) </ td >
</ tr >
</ table >
</ body >
</ html >
转载于:https://www.cnblogs.com/hahacjh/archive/2010/05/16/1736575.html
最后
以上就是冷静小甜瓜为你收集整理的内嵌框架自适应页面大小 js语句的全部内容,希望文章能够帮你解决内嵌框架自适应页面大小 js语句所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复