Put HTML head in another file(将 HTML 头放在另一个文件中)
问题描述
有没有办法将所有 meta tag
、link rel
和 script src
包含在一个文件中,然后要求该文件?
Is there a way to include all the meta tag
, link rel
and script src
includes in one file, and then require that file?
我问的原因是因为我有 10-15 行要复制到每个文件中,并认为可能有另一种方法.
The reason I ask is because I have like 10-15 lines that i am copying into every file and figured there might be another way.
我将所有内容都放在一个文件中,并尝试了 Jquery 加载功能,但无济于事.
I put everything in one file and tried the Jquery load function, but to no avail.
谢谢
推荐答案
像这样创建一个 head.html 文件:
Create a head.html file like this:
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- Meta -->
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<!-- JS -->
<script type="text/javascript" src="js/lib/jquery-1.11.min.js" ></script>
<script type="text/javascript" src="js/lib/angular.min.js"></script>
<title>Your application</title>
现在在您的 HTML 页面中包含 head.html,如下所示:
Now include head.html in your HTML pages like this:
<head>
<script type="text/javascript" src="js/lib/jquery-1.11.1.min.js" ></script>
<script>
$(function(){ $("head").load("head.html") });
</script>
</head>
这篇关于将 HTML 头放在另一个文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将 HTML 头放在另一个文件中


基础教程推荐
- 如何添加到目前为止的天数? 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01