Include html in another html file [duplicate] Include html in another html file [duplicate] javascript javascript

Include html in another html file [duplicate]


Method 1:

I think it would be best way to include an html content/file into another html file using jQuery.

You can simply include the jQuery.js and load the HTML file using $("#DivContent").load("yourFile.html");

For example

<html>   <head>     <script src="jquery.js"></script>     <script>     $(function(){      $("#DivContent").load("another_file.html");     });    </script>   </head>   <body>      <div id="DivContent"></div>  </body> </html>

Method 2:

There are no such tags available to include the file but there are some third party methods available like this:

<!DOCTYPE html><html><script src="http://www.w3schools.com/lib/w3data.js"></script><body><div w3-include-html="content.html"></div> <script>w3IncludeHTML();</script></body></html>

Method 3:

Some people also used server-side-includes (SSI):

<!--#include virtual="a.html" --> 


Use <object> tag:

<object data="filename.html"></object>


Using HTML tag.

I have faced similar problem , then I used

<iframe src = "b.html" height="80px" width="500px" >