Splitting up a html page and loading it through header?(拆分一个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页面并通过标题加载它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:拆分一个html页面并通过标题加载它?
基础教程推荐
- 在for循环中使用setTimeout 2022-01-01
- 响应更改 div 大小保持纵横比 2022-01-01
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01
- 动态更新多个选择框 2022-01-01
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- 我什么时候应该在导入时使用方括号 2022-01-01
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01
- 悬停时滑动输入并停留几秒钟 2022-01-01