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

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

问题描述

有没有办法将所有 meta taglink relscript 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 头放在另一个文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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