关于网页头的问题
2007-03-29 10:56
225 查看
在一些网页中,有些人会把相同的头单独做成一个网页head.asp,而在别的页面的<body></body>之间用<!--include file="head.asp"-->调用,这样显得很方便。include 的作用就是相当于把被包含的文件中的代码放在使用include的地方,举个例子:
1.asp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<!--#include file="2.asp"-->
</body>
</html>
2.asp
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
</table>
这时的1.asp其实就相当于:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
自己体会一下,一般情况下,被include的文件中,<html> <head>等标记都最好删除,否则可能引起显示混乱,因为相当于一个文件中有两对<html>等的标记了。
另外,一般来说,静态的HTML页面没有include功能,但是我们可以利用<script>的功能,举例如下:
//header.js:
aa="<head><title>aaa</title></head>";
document.write(aa);
//test.htm:
<script language="javascript" src="header.js"></script>
<body>hello</body>
OK, 你就可以看到include的效果了。
还有一个办法就是把静态页面改成动态页面,即把文件后缀改成asp,再使用<!--#include file="包含的文件名"-->,不过这样会降低速度,因为asp文件需要在IIS里先运行。
1.asp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<!--#include file="2.asp"-->
</body>
</html>
2.asp
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
</table>
这时的1.asp其实就相当于:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
自己体会一下,一般情况下,被include的文件中,<html> <head>等标记都最好删除,否则可能引起显示混乱,因为相当于一个文件中有两对<html>等的标记了。
另外,一般来说,静态的HTML页面没有include功能,但是我们可以利用<script>的功能,举例如下:
//header.js:
aa="<head><title>aaa</title></head>";
document.write(aa);
//test.htm:
<script language="javascript" src="header.js"></script>
<body>hello</body>
OK, 你就可以看到include的效果了。
还有一个办法就是把静态页面改成动态页面,即把文件后缀改成asp,再使用<!--#include file="包含的文件名"-->,不过这样会降低速度,因为asp文件需要在IIS里先运行。
相关文章推荐
- 网页端的utf8和gb2312 之间关于osd 传参数的乱码问题
- 关于cefglue调试过程中打不开网页的问题
- 关于网页排版背景图片的问题
- 关于《网页中使用天堂免费计数器》的问题
- 关于无法显示该网页,弹出对话框显示"Internet Explorer无法打开Internet站点xxx,已终止操作"问题的解决方法
- 关于网页头部的一些问题
- 2010年4月2日,关于网页压缩的问题。
- 关于打印机打印网页出现字迹显示不全的问题心得
- 关于Struct2 代码没错,加载网页莫名出现404问题。
- 关于Jsoup解析https网页的问题
- 关于微信WEBVIEW网页无法上传文件的问题,即是INPUT FILE不支持的问题
- 关于DreamWaver制作的网页无法播放背景音乐和动画的问题
- 关于网页居中的问题
- 关于网页极速模式 兼容模式问题
- 关于JTidy整洁网页一个常见问题
- 关于php安装后打开网页上空白问题的解决方法
- 关于WebView不能加载网页,配置,兼容适配问题
- 关于微信端打开网页,不支持第三方的微信支付的问题
- 关于做网页投票、客户计数的存储问题
- [PHP+MySQL开发基础分享]关于PHP会话和网页中文乱码的问题