拆分一个html页面并通过标题加载它?

2023-02-15前端开发问题
7

本文介绍了拆分一个html页面并通过标题加载它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在使用 HTML5,并希望通过将标准 HTML 模板拆分为三个单独的 HTML 文件来加快创建和编辑的速度.

I am using HTML5, and would like to speed up the creation and editing of my standard HTML template by splitting it into three separate HTML files.

  • header.html
  • content.html(这将被编辑并具有其他名称,例如 home)
  • 页脚.html

我查看了以下资源,但我不确定这是否可行或如何去做.

I have looked at the following resources, but I am not sure if this is possible or how to go about it.

http://www.w3schools.com/html/html_head.asp

http://www.w3schools.com/tags/tag_link.asp

在 PHP 中,我只会按正确的顺序包含文件.在纯 HTML 网站中是否有等价物?

In PHP I would just include the files in the right order. Is there an equivelant in just a plain HTML site?

我已经用谷歌搜索了这个,但我认为我没有找到正确的术语.我将不胜感激任何可用的信息或资源!

I have googled this, but I don't think Im searching for the right term. I would appreciate any information, or resources available!

感谢您的宝贵时间!

推荐答案

对于一个静态 HTML 站点,没有 html-only 方法可以按照您尝试的方式包含文件.您可能能够使用服务器端包含,具体取决于您的服务器,但到那时,您还不如只使用 PHP.

For just a static HTML site, there is no html-only way to include files the way you are trying to. You may be able to use server-side includes depending on your server, but by that point, you might as well just use PHP.

另一种选择是在页面的主要部分已经加载后广泛使用 Javascript 来加载页面片段.

Another option would be to make extensive use of Javascript to load the page pieces after the main part of the page is already loaded.

但是,在所有情况下,性能都会大大降低,因为服务器请求很慢.如果您需要使用模板,只需使用 PHP 等动态语言即可.

In all cases, though, you will have a major reduction in performance, since a server request is slow. If you need to use templates, just use a dynamic language like PHP.

这篇关于拆分一个html页面并通过标题加载它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

layui 实现实时刷新一个外部的div
主页面上显示了一个合计,在删除和增加的时候需要更改这个总套数的值: //html代码div class="layui-inline layui-show-xs-block" style="margin-left: 10px" id="sumDiv"spanSOP合计:/spanspan${totalNum}/spanspan套/span/div 于是在我们删除这个条数据后,...
2024-11-14 前端开发问题
156

layui tree树组件怎么自定义添加图标
经常用到layui的朋友都知道,layui tree默认是不能自定义图标的,那么我们要自定义的话要怎么操作呢? 首先用编辑器软件(修改时候用编辑器记得编码),打开layui.js。搜索: i class="layui-icon layui-icon-file" 改为如下代码: i class="'+ (i.icon || "l...
2024-10-26 前端开发问题
493

layui要如何改变时间日历布局大小?
问题描述 我想改变layui时间日历布局大小,这个要怎么操作呢? 解决办法 可以用css样式对时间日历进行重新布局,具体代码如下: !DOCTYPE htmlhtmlheadmeta charset="UTF-8"title/titlelink rel="stylesheet" href="../../layui/css/layui.css" /style#test-...
2024-10-24 前端开发问题
271

jQuery怎么动态向页面添加代码?
append() 方法在被选元素的结尾(仍然在内部)插入指定内容。 语法: $(selector).append( content ) var creatPrintList = function(data){ var innerHtml = ""; for(var i =0;i data.length;i++){ innerHtml +="li class='contentLi'"; innerHtml +="a href...
2024-10-18 前端开发问题
125

“数组中的每个孩子都应该有一个唯一的 key prop"仅在第一次呈现页面时
quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)...
2024-04-20 前端开发问题
5

CoffeeScript 总是以匿名函数返回
CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)...
2024-04-20 前端开发问题
13