當前位置:編程學習大全網 - 網站源碼 - 求:壹段網頁源代碼,可以引用本網頁前面已存在的源代碼。

求:壹段網頁源代碼,可以引用本網頁前面已存在的源代碼。

可以使用外部引用 <!-- #include PathType = FileName --> 通過兩次引用實現兩次使用相同代碼!

比如:

<!-- #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

測試

  • 上一篇:中通快運400投訴電話多少
  • 下一篇:在HTML中什麽是格式化?
  • copyright 2024編程學習大全網