iframe自适应网页
来源:互联网 发布:板生产软件 编辑:程序博客网 时间:2024/05/07 23:24
frame.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>iframe自适应高度.htm</title>
<meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> -->
</head> <body> 两个iframe也是没有影响的,只要把在另一个iframe的页面中把javascript再复制一遍就行! <div><iframe src="iframe_include.jsp" frameborder="1"></iframe></div> <!-- div><iframe src="iframe_include2.jsp" frameborder="1"></iframe></div-->
</body> </html>
frame_include.jsp文件:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>iframe自适应网页</title>
<meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> <script type="text/javascript">
//自动调整iframe框架的方法
function iframeAuto()
{
try
{
if(window!=parent)
{
//定位需要调整的frame框架(在父级窗口中查找)
var a = parent.document.getElementsByTagName("IFRAME");
for(var i=0; i<a.length; i++)
{
if(a[i].contentWindow==window)
{
var h1=0, h2=0;
a[i].parentNode.style.height = a[i].offsetHeight +"px";
a[i].style.height = "10px"; //首先设置高度为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){}
}
//事件绑定的方法,支持IE5以上版本
if(window.attachEvent)
{
window.attachEvent("onload", iframeAuto);
}
else if(window.addEventListener)
{
window.addEventListener('load', iframeAuto, false);
}
//-->
</script>
</head>
<body>
<table border="1" width="200" style="height:400px; background-color: gray">
<tr>
<td> iframe 自适应其加载的网页 </td>
</tr>
</table>
</body>
</html>
- IFRAME自适应网页
- iframe自适应网页
- 再谈iframe自适应高度-网页设计
- iframe自适应
- iframe 自适应
- 自适应iframe
- iframe 自适应
- iframe自适应
- iframe自适应
- iframe自适应
- iframe自适应
- iframe 自适应
- iframe自适应
- iframe 自适应
- Iframe自适应
- iframe 自适应
- 使iframe自适应内含网页的高度和宽度
- 利用js让iframe框架自适应网页高度
- ServerVariables 服务器变量大全[ASP]
- DispatchAction用法的详细代码
- C#学习笔记(4)----- 属性与修饰符
- 数学和数学库函数,你还记得多少?
- 关于COOKIES跨域总结(通过一个问题)
- iframe自适应网页
- ASP动态网页编程的19个基本技巧
- ASP编程常用的代码推荐
- 微软经典变态的面试题
- 开博了
- Linux系统命令汇总之系统备份常用命令
- Flame与计算机连线时上网仍连接GPRS的解决办法
- Linux常用指令速查手册
- STOP 0x0000001D or STOP 0x000000A Stop Error Occurs in Ndis.sys