简体   繁体   English

例如,如何在不手动更改所有页面的情况下,编辑一个HTML文件的标题并使它对所有其他页面都相同?

[英]How to edit, for example, the header of one HTML file and make it do the same to all other pages, without changing all the pages manually?

More in-depth; 更深入; for example, about any website at the moment has a navigation bar. 例如,目前任何网站都具有导航栏。 With hundreds of pages, as an example, how would you edit it accordingly on one page - which will modify the navigation bar on all other pages you've got without changing each page its navbar manually? 以数百个页面为例,如何在一个页面上进行相应的编辑-这将修改您拥有的所有其他页面上的导航栏,而无需手动更改每个页面的导航栏?

All you need to do is to create a common have header file and include in every page. 您需要做的就是创建一个通用的头文件,并将其包含在每个页面中。

This can be done with PHP s include or require . 这可以通过PHP的includerequire来完成。

well, it depends: because this task is normally performed by the server , each server platform manage this problem in a different way. 好吧,这取决于:因为此任务通常由服务器执行,所以每个服务器平台都以不同的方式管理此问题。 for instance : ASP.NET applications using a MasterPage mechanism in order to define a main template for the entire site, with "frames" that changes from page to page. 例如 :使用MasterPage机制的ASP.NET应用程序,以便为整个站点定义一个主模板,其“框架”在页面之间变化。

on the client side this is normally performed by iframe tags... so it really depends which platform are you using and if your stratedgey focus on the server side or on the client side 客户端,这通常是由iframe广告代码执行的...因此,这实际上取决于您使用的平台以及您的策略是集中在服务器端还是客户端

Well a shortcut, you could do this. 好快捷方式,您可以执行此操作。

Index.php Index.php

   ///header code
              <? 
if(empty($pg))
$var = "p/home.php";

if(empty($_SERVER["QUERY_STRING"])) {
include($var);
} else {
include("p/$pg.php");
}
?>
    ////footer code

Now just link you links to "?pg=NAME_OF_THE_PAGE" without the ".php" and you will have a standard index that you can chage menu, header and footer that will change for all pages. 现在,只需将您的链接链接到没有“ .php”的“?pg = NAME_OF_THE_PAGE”,您将拥有一个标准索引,您可以更改菜单,页眉和页脚,所有页面都将更改。

Note: the pages that you will create, just put the content, with no header or footer. 注意:您将创建的页面仅放置内容,没有页眉或页脚。

Hope it helps. 希望能帮助到你。

As programming student said, use include or require : 正如编程学生所说,使用includerequire

header.php header.php

<div class="header">
   <p>this is a header</p>
</div>

index.php index.php

<?php require_once 'header.php'; ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何一次将相同的页眉和页脚添加到所有页面? HTML - How to add the same header and footer to all pages at once? HTML 我该如何插入 <div> (其中包含我的菜单)进入所有其他html页面? - How do I insert the same <div> (which contains my menu) into all other html pages? http to https-使浏览器为http URL请求相应的https URL,而无需编辑所有页面并将所有URL手动更改为https? - http to https - Make browser request corresponding https URLs for http URLs, without needing to edit all pages and manually change all URLs to https? 如何在所有HTML页面中弹出一次? - How to make one time popup in all HTML pages? 在所有页面上打印相同的页眉 - Print the same header on all pages HTML 页面 - 所有 HTML 页面中的顶部菜单(页眉)和页脚是否相同? - HTML Page - same top menu (header) and footer in all HTML pages? 如何将所有快递页面路由到一个独特的页面(没有 html 扩展名) - How to route all express pages to a unique pages (Without html extension) 在html文档的所有页面中打印标题而不会重叠 - Print header in all pages of a html document without overlapping 制作相同<head>可用于所有页面 - Make same <head> available to all pages 如何确保所有 HTML 页面的字体发生变化? - How do I make sure the font changes across all HTML pages?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM