[英]Copy two different html pages content into one page
我有2個不同的靜態html頁面( a.html
和b.html
),我想將這2個html頁面的內容復制到c.html頁面中。 我通過此鏈接 。 任何解決方案,如何將兩個html頁面內容復制到一頁中?
任何JQuery或JavaScript邏輯?
您可以使用jquery。 例如 :
$( "#a" ).load( "article.html" );
$( "#b" ).load( "article2.html" );
或者如果您不想分割內容,請使用append()函數。 像這樣
在您的c.html上有一個div容器。 您希望每個HTML內容都有一個容器,以便您可以指定要附加的html的位置。
<div id="container">
<div id="a">
</div>
<div id="b">
</div>
</div>
進行2個ajax調用以追加a.html
和b.html
的內容
$("#a").append($.get("/a.html"));
$("#b").append($.get("/b.html"));
當然,通過服務器端更容易做到這一點,但是如果您希望它成為所有前端,那么它將起作用。
HTML框架可用於拆分網頁,因此您可以將多個HTML文件或頁面加載到一個網頁中。 這將導致網絡瀏覽器一次顯示多個頁面。 我想使用的這種技術的一個常見示例是在瀏覽器窗口的左側顯示帶有說明和鏈接的文檔索引,因此當讀者單擊鏈接時,該頁面將顯示在頁面的右側。瀏覽器窗口。
<html>
<head>
<title>Multiple pages in one page</title>
<head>
<frameset border="1" cols="200,*" frameBorder="0" frameSpacing="4">
<noframes>
<body>
<p>
You should include HTML here to support webcrawlers and browsers that don't support frames.
You may want to include a second copy of your index, and set your wallpaper and colors
in the BODY statement above the same as you would in your index file.
</p>
</body>
</noframes>
<frame name="left" src="htmlindex.html">
<frame name="right" src="htmlintroduction.html">
</frameset>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.