如何在另一个页面中包含html页面?
问题描述:
我想为index.html页面创建一个弹出窗口。我有一个演示,弹出窗口将出现在网页的右下角。 但我的演示是由jsp写的,而不是html。如何在另一个页面中包含html页面?
<jsp:include page="popup.html" flush="true" ></jsp:include>
它工作正常。
但在html中,这行不起作用。我曾尝试过:
<!--#include virtual="popup.html" -->
<!--#include file="popup.html" -->
但没有弹出窗口。
那么,有没有包括popup.html。谢谢!
答
要使用<!--#include
,你需要确保你的Web服务器已经启用Server Side Includes。
你也可以使用一个基于服务器的语言如PHP,这将做到这一点使用功能,如readfile()
。
在纯HTML,我怀疑你唯一的选择将包括<iframe>
内第二HTML文件。这绝不是一个理想的解决方案,但如果没有别的办法可行,这可能。
尝试使用iFrame ... – 2012-03-28 03:26:26
只能通过XHR,但它需要额外的HTTP请求。 – 2012-03-28 03:27:36
可能的重复http://*.com/questions/676394/how-to-include-an-html-page-into-an-html-page - 看看[这个答案](http://*.com/a/676409/983430)了解如何使用jQuery进行此操作。 – 2012-03-28 03:50:59