![](/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.