这里面除了div和iframe之外,还需要一段自适应高度的教本。div层就是放网页顶部的菜单栏,iframe部分是子窗体。我把主页的代码复制如下:
<html>
<head>
<title>iframe自适应加载的页面高度</title>
<script language="Javascript">
var getFFVersion=navigator.userAgent.substring
(navigator.userAgent.indexOf("Firefox")).split("/")[1]
//extra height in px to add to iframe in FireFox 1.0+ browsers
var FFextraHeight=getFFVersion>=0.1? 16 : 0
function dyniframesize(iframename) {
var pTar = null;
if (document.getElementById){
pTar = document.getElementById(iframename);
}
else{
eval('pTar = ' + iframename + ';');
}
if (pTar && !window.opera){
//begin resizing iframe
pTar.style.display="block"
if (pTar.contentDocument &&
pTar.contentDocument.body.offsetHeight){
//ns6 syntax
pTar.height =
pTar.contentDocument.body.offsetHeight+FFextraHeight;
}
else if (pTar.Document && pTar.Document.body.scrollHeight){
//ie5+ syntax
pTar.height = pTar.Document.body.scrollHeight;
}
}
}
</script> </head>
<body>
<div class="phdn" align=center>
<a href="#" target="main">资讯首页</a>
|
<a href="child1.htm" target="main">财经</a>
|
<a href="child2.htm" target="main">体育</a>
|
<a href="child3.htm" target="main">娱乐</a>
|
<a href="child4.htm" target="main">汽车</a>
|
<a href="child5.htm" target="main">房产</a>
|
<a href="child6.htm" target="main">科技</a>
|
<a href="child7.htm" target="main">访谈</a>
|
<a href="child8.htm" target="main">旅游</a>
|
<a href="child9.htm" target="main">社会</a>
|
<a href="child10.htm" target="main">社区</a>
</div>
<iframe id="myTestFrameID" name="main" onload="javascript:{dyniframesize('myTestFrameID');}"
marginwidth=0 marginheight=0 frameborder=0 scrolling=no src="child1.htm" width=100% ></iframe>
</body></html>
//*****************
// child.htm就是需要替换的子窗体。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端
2007-05-17 在.net中使用xmlhttp组件读取网页源码
2006-05-17 初学ASP.Net时一些备忘的东西
2006-05-17 如何给Asp.Net表格或控件加上自定义的提示框?
2006-05-17 如何显示在线人数,和所在位置?? [转自作者:子扬]