本文介紹了將 HTML 頭放在另一個文件中的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
有沒有辦法將所有 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模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!