我有两个HTML文件,假设是a.html
和b.html
.在a.html
中我想包括b.html
.
在JSF中,我可以这样做:
<ui:include src="b.xhtml" />
这意味着在a.xhtml
个文件中,我可以包含b.xhtml
个.
我们怎么能在*.html
档里做到这一点呢?
我有两个HTML文件,假设是a.html
和b.html
.在a.html
中我想包括b.html
.
在JSF中,我可以这样做:
<ui:include src="b.xhtml" />
这意味着在a.xhtml
个文件中,我可以包含b.xhtml
个.
我们怎么能在*.html
档里做到这一点呢?
在我看来,最好的解决方案是使用jQuery:
a.html
:
<html>
<head>
<script src="jquery.js"></script>
<script>
$(function(){
$("#includedContent").load("b.html");
});
</script>
</head>
<body>
<div id="includedContent"></div>
</body>
</html>
b.html
:
<p>This is my include file</p>
这个方法简单明了地解决了我的问题.
jQuery.load()
文档是here.