比如:
<!-- #include file = "myfile.inc" -->
<!-- #include virtual = "/scripts/tools/global.inc" -->
這樣如果需要修改只需要改動引用的文件本身就能夠實現所有都改動完畢。
當然也可以使用:框架、模板等其他形式。
對於問題補充的回答:
不能直接在使用html的,<!-- #include file = "myfile.inc" -->是屬於shtml裏的ssi(具體說明看參考資料),得在支持shtml的服務器軟件環境下運行,IIS 和 Apache 都支持的!
比如:
demo.shtml文件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>demo</title>
</head>
<body>
<!--#include file="include.inc" -->
<p>a</p>
<!--#include file="include.inc" -->
</body>
</html>
include.inc
<p>測試</p>
運行結果:
測試
a
測試