作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个网站,我有页眉和页脚,我会不断更改它们。我有大约 69 个 html 页面,它们是用 HTML 4.01 编写的。我怎样才能做到这一点,以便我必须更改索引页面中的代码,并且所有其他页面都会更改?
我尝试使用 Javascript,但它非常乏味并且不会产生相同的结果。
最佳答案
编写 php 代码,它将在所有页面中呈现两个 php 文件(如示例 top.php 和 Bottom.php)的内容。您可以更改该文件的内容。我认为它看起来像一个小部件)。
看看这个简单的示例:
top.php:
<?php
echo "top content<br>";
底部.php:
<?php
echo "<br>bottom content";
index.php:
<?php require_once("top.php"); ?>
content
<?php require_once("bottom.php"); ?>
结果 html 是:
top content
<br>
content
<br>
bottom content
您可以更改top.php和bottom.php,它将更改index.php中的内容。如果您使用 php 服务器脚本语言;)
关于javascript - 更改所有 html 页面上的页眉/页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12975502/
我是一名优秀的程序员,十分优秀!