将HTML头放在另一个文件中 [英] Put HTML head in another file

查看:133
本文介绍了将HTML头放在另一个文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以包含所有元标记链接rel 脚本src 包含在一个文件中,然后需要该文件?



我问的原因是因为我有10-15行,复制到每个文件,并认为可能有另一种方式。

我把所有内容放在一个文件中,并尝试Jquery加载函数,但无济于事。



感谢

解决方案

创建一个 head.html 文件这个:

 < link rel =stylesheethref =css / bootstrap.min.css> 
<! - Meta - >
< meta http-equiv =Content-Typecontent =text / html; charset = ISO-8859-1>
<! - JS - >
< script type =text / javascriptsrc =js / lib / jquery-1.11.1.min.js>< / script>
< script type =text / javascriptsrc =js / lib / angular.min.js>< / script>
< title>您的应用程式< / title>

现在,在您的HTML页面中包含 header.html : p>

 < head> 
< script type =text / javascriptsrc =js / lib / jquery-1.11.1.min.js>< / script>
< script>
$(function(){$(head)。load(header.html)});
< / script>
< / head>


Is there a way to include all the meta tag, link rel and script src includes in one file, and then require that file?

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.

I put everything in one file and tried the Jquery load function, but to no avail.

Thanks

解决方案

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.1.min.js" ></script>
<script type="text/javascript" src="js/lib/angular.min.js"></script>
<title>Your application</title>

Now include header.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("header.html") });
   </script>
</head>

这篇关于将HTML头放在另一个文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆