有没有办法将所有 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 头放在另一个文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在 javascript 认为文档“准备好"之前,如何让How can I get my jasmine tests fixtures to load before the javascript considers the document to be quot;readyquot;?(在 javascript 认为文档“准备好
jasmine 运行和等待实际上是做什么的?What do jasmine runs and waitsFor actually do?(jasmine 运行和等待实际上是做什么的?)
如何提供模拟文件来更改 <input type='filHow to provide mock files to change event of lt;input type=#39;file#39;gt; for unit testing(如何提供模拟文件来更改 lt;input type=filegt; 的事
如何使用 Jasmine 对链式方法进行单元测试How to unit test a chained method using Jasmine(如何使用 Jasmine 对链式方法进行单元测试)
如何将 $rootScope 注入 AngularJS 单元测试?How do I inject $rootScope into an AngularJS unit test?(如何将 $rootScope 注入 AngularJS 单元测试?)
Jasmine - 如何监视函数中的函数调用?Jasmine - How to spy on a function call within a function?(Jasmine - 如何监视函数中的函数调用?)