【发布时间】:2015-06-26 13:28:05
【问题描述】:
我想在我的所有页面中包含页眉和页脚。我可以使用 include() 函数将其包含在 php 中。但我只有 .html 文件。那么是否有任何 html 标记来包含另一个 html 文件。
【问题讨论】:
-
如果你的服务器支持,可以使用Server Side Includes
标签: javascript jquery html
我想在我的所有页面中包含页眉和页脚。我可以使用 include() 函数将其包含在 php 中。但我只有 .html 文件。那么是否有任何 html 标记来包含另一个 html 文件。
【问题讨论】:
标签: javascript jquery html
使用 jquery 你可以做一个 ajax 请求:
$('footer').load('/yourPage.html', function () {
//if you need to do something after
});
【讨论】:
使用 HTML 导入
<head>
<link rel="import" href="/path/to/file/file.html">
</head>
并将其用于:
var content = document.querySelector('link[rel="import"]').import;
【讨论】: