How to include html files like include in php?

How can we include files inside html, for example, as usual, we add files to Php.

<?php include "nav.php";?> 
+6
source share
5 answers

You can use jQuery:

HTML

 <div id="container"></div> 

JQuery

 $("#container").load('somepage.html'); 

Learn more about the load function and what you can do with it in the documentation .

+3
source

You can use Ajax, see the jQuery download function , for example:

 <div id="moreData"></div> $( "#moreData" ).load( "otherPage.html" ); 
+2
source

My suggestion would be to use jQuery.

 <html> <head> <script src="jquery.js"></script> <script> $(function(){ $("#includeCont").load("file.html"); }); </script> </head> <body> <div id="includeCont"></div> </body> </html> 
+2
source

Use ifrmae

 <!DOCTYPE html> <html> <body> <iframe src="http://www.w3schools.com"> <p>Your browser does not support iframes.</p> </iframe> </body> </html> 

Or use frameset

 <!DOCTYPE html> <html> <frameset cols="25%,*,25%"> <frame src="http://www.w3schools.com/frame_a.php"> <frame src="http://www.w3schools.com/frame_b.php"> <frame src="http://www.w3schools.com/frame_c.php"> </frameset> </html> 
+1
source

There is a round method using http://httpd.apache.org/docs/current/howto/ssi.html

On the server side there is

For example, <!--#include virtual="/footer.html" -->

0
source

All Articles