html入门问题

来源:百度知道 编辑:UC知道 时间:2024/05/12 01:31:28
很多网页都要用一样的header 和footer,怎么实现类似那种include的命令,就是只编写一个header和footer file

静态html是不支持的
这里介绍在现在最常见的三种动态语言(asp,php,jsp)里的include指令:
比如现在有三个文件,一个是头部(我们就命名header),一个是正文(index),一个是尾部(footer)

1.asp中:
文件名就命名为header.asp,index.asp和footer.asp
其中header.asp里面的代码比如写成
<html><header></header><body>

footer.asp里面的代码写成
</body></html>

那index.asp里面的代码就写成
<!--#include file="header.asp" -->
中间这里写正文内容
<!--#include file="footer.asp" -->

这个index.asp的主体页面就完成了

2.php中的文件后缀名都是.php
这里就是header.php,index.php和footer.php了
include语法就是
<?php include("header.php"); ?>

帮上面的<!--#include file="header.asp" -->之类的
换成<?php include("header.php"); ?>就行了

3.在jsp中:
同样,三个文件是header.jsp,index.jsp和footer.jsp
include语法是<%@ include file="header.jsp" %>

也相应地换下就OK了!

这三种中以asp最常见
一般的收费空间都支持asp,也是最便宜的动态空间