简体   繁体   English

在HTML中将一个页面内容插入另一个页面

[英]insert one page content to the another page in html

 <script src="jquery.js"></script> <header id="menu-header"> //menu bar </header> <script> $(function(){ $("#menu-header").load("header.html"); }); </script> 

Here I want to include my header menu into different html pages. 在这里,我想将标题菜单包含到不同的html页面中。 How to include one html header into each page? 如何在每个页面中包含一个html标头? I have already used jQuery load function but it is not working in Chrome. 我已经使用了jQuery load功能,但是在Chrome中无法正常工作。

//menu bar //菜单栏

You can do using jQuery Get Request. 您可以使用jQuery Get Request做。

For example here is menu.html file 例如,这里是menu.html文件

<ul>
    <li><a href="www.naveedramzan.com" title="Home">Home</a>
    <li><a href="www.naveedramzan.com/about-naveed" title="About">About</a>
</ul>

Here is index.html file 这是index.html文件

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<div id="menu"></div>
<script>
    $(document).ready(function(){
        $.get( "menu.html", function( data ) {
          $( "#menu" ).html( data );
        });
    });
</script>

jQuery will load menu.html file and add html in #menu and that you can do on all pages jQuery将加载menu.html文件并在#menu添加html,并且您可以在所有页面上执行此操作

This node.js library will help you; 这个node.js库将为您提供帮助; templatesjs ; templatejs ;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将HTML页面中的“添加/插入”按钮从一个域添加到另一个域 - Append / Insert button from a HTML page from a domain to another one 如何使用AngularJS中的自定义指令将一个html页面插入另一个html页面? - How to insert one html page into another html page using custom directive in AngularJS? 如何从一个json文件将一个对象的内容输出到一个html页面,而将另一个对象的内容输出到另一个html页面? - How to output from one json file the content of one object to one html page and the contents of another object to another html page? 在 HTML 中将数据一个页面发送到另一个页面 - Send Data one page to another page in HTML 如何使用javascript将一个html页面上的div内容与另一页面上的div内容更改? - How to change the content of a div on one html page with the contents of a div from another page using javascript? 使用Javascript将段落从外部HTML页面插入到另一个HTML页面 - Insert a paragraph from an external HTML page to another HTML page with Javascript jQuery 插入外部 html 页面<title>进入另一个html页面 - jQuery Insert external html page <title> into another html page 如何从另一个html页面获取html页面的内容? - How to get the content of a html page from another html page? 快速将HTML插入另一个网页 - Insert HTML into another Web page on the fly 使用 javascript 将 html 插入另一个页面? - insert html into another page using javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM