像某些大网站一样,网页顶部标题不变,只动态刷新子窗体
2006-11-01 16:47
351 查看
最近做一个网站,因为头部菜单栏都是一样的嘛,所以想实现跟标题一样的效果。开始我想到的就是框架,具体实施的时候发现不行,上下两部分不能很好的结合。CSDN上问,看到一个网友的问题跟我类似,有人提示用div和iframe实现,可惜没给出具体方法。只能自己查资料,最后终于搞定呵呵 。
这里面除了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就是需要替换的子窗体。
其实用,<!--#include file="top.asp"-->得方法也可以,多掌握种办法也是有好处的吧。
这里面除了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就是需要替换的子窗体。
其实用,<!--#include file="top.asp"-->得方法也可以,多掌握种办法也是有好处的吧。
相关文章推荐
- 像某些大网站一样,网页顶部标题不变,只动态刷新子窗体
- 原创asp.net动态添加网站seo的标题、关键词、描述的方法
- 在动态页面里象静态页面一样控制整个网页的缓存和更新
- 动态改变asp.net网页的标题!
- java 使用正则表达式从网页上提取网站标题
- html .net 网页,网站标题添图标
- 如何用Python,C#等语言去实现抓取静态网页+抓取动态网页+模拟登陆网站
- 怎么把当前网站的所有.aspx动态网页转换成.html静态网页进行浏览呢?
- (转)Python-详解抓取网站,模拟登陆,抓取动态网页的原理和实现
- 【转】详解抓取网站,模拟登陆,抓取动态网页的原理和实现(Python,C#等)
- 关于C#窗体登录网站获取网页Cookie
- 动态改变asp.net网页的标题!
- JS实现网页动态标题
- 网站动态标题设定
- 网站顶部的固定淡出菜单 --- 可以实现新浪微博顶部导航菜单一样的效果
- 使网站logo小图标显示在网页标题前面
- 网站导航条固定在网页顶部不动
- 网页顶部或者底部广告代码 可定时关闭 可用于网站通知等
- [置顶] 【实战】如何通过html+css+mysql+php来快速的制作动态网页(以制作一个博客网站为列)
- Asp.Net网页头部动态加载标题、描述、关键字、css和js文件的方法