[英]How do I load a webpage inside a div using Javascript without IFRAME and JQuery?
[英]How do I load a webpage inside a div using Javascript without IFRAME?
我需要將外部網頁加載到div中。 我不想使用iFrame。 我想用普通的Javascript或Jquery完成這個。 我不知道該怎么做。
$( "#DIVID" ).load( "Path" );
它會將你的html數據加載到任何div中。
有很多方法,這里有一對:
http://www.w3schools.com/jquery/jquery_ajax_load.asp
$( "#result" ).load( "ajax/test.html" );
http://api.jquery.com/jquery.ajax/
$.ajax({
url: "test.html",
context: document.body
}).done(function() {
$( this ).addClass( "done" );
});
使用<jsp:include>
標記可以輕松解決此問題。 但我不想推薦。 它只是將另一個JSP文件附加到模板。
template.jsp
<div id="HSpace">
<jsp:include page="Header.jsp" flush="true" />
</div>
<div id="MSpace">
<jsp:include page="Main.jsp" flush="true" />
</div>
<div id="TSpace">
<jsp:include page="Tail.jsp" flush="true" />
</div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.