![](/img/trans.png)
[英]How to include partial html file into another html file using gulp?
[英]Create full HTML file using partial HTML
我有一個主要的html頁面(index.html),並且需要動態組合幾個html文件(custom_header_page.html/ custom_content_page.html/ custom_footer_page.html)
來構造該頁面頁面。
我正在尋找一種無需任何服務器端腳本編寫即可完成的方法。
例如:
custom_header_page.html
custom_body_page.html
custom_footer_page.html
只是對index.html文件中的內容感到厭倦,是的,它可以正確加載,但是我想用在“ custom_header.html”文件中添加的內容覆蓋index.html的<head> </head>
內容。
index.html
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" type="text/javascript"> </script>
<title>Title</title>
</head>
<body>
<div id="custom_header"></div>
<div id="custom_body"></div>
<div id="custom_footer"></div>
<script>
$(function(){
$("#custom_header").load("custom_header_page.html");
$("#custom_body").load("custom_body_page.html");
$("#custom_footer").load("custom_footer_page.html");
});
</script>
</body>
您不能在不使用服務器端(例如php)的情況下編輯文件,可以使用jquery編輯html標頭,但這只能在本地瀏覽器上進行,其他用戶都不會改變。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.