gpt4 book ai didi

javascript - 更改所有 html 页面上的页眉/页脚

转载 作者:行者123 更新时间:2023-12-02 19:17:21 30 4
gpt4 key购买 nike

我有一个网站,我有页眉和页脚,我会不断更改它们。我有大约 69 个 html 页面,它们是用 HTML 4.01 编写的。我怎样才能做到这一点,以便我必须更改索引页面中的代码,并且所有其他页面都会更改?

我尝试使用 Javascript,但它非常乏味并且不会产生相同的结果。

Example of a site

最佳答案

编写 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/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com