Include one HTML file in another HTML file using the server side.

How to include an HTML file in another HTML file. Is there an easy way to do this?

thanks

+4
source share
6 answers

I think you are looking for the back end: http://en.wikipedia.org/wiki/Server_Side_Includes . To summarize (and simplify), change the extension of your page from .html to .shtml, then you will need to use an include statement similar to:

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

+5
source

You may be looking for information about iframe s ( live example ).

 <html> <body> <iframe src ="/default.asp" width="100%" height="300"> <p>Your browser does not support iframes.</p> </iframe> </body> </html> 
+2
source

Do you serve HTML files from a web server such as IIS or Apache? Both sides of the support include:

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

A page in the WWW FAQ section.

+1
source

Well, if you have any server-side scripting language, all of this will do the job perfectly. Another option is html-frames (in your case, most likely iframe), or ajax (asynchrounus javascript request).

0
source

My preferred method uses PHP if it is installed on your server. If so, the easiest way to do this is to simply paste this code in the right place in the file containing the file: <?php include('filename.php') ?>

Note that both files must have a .php extension.

0
source

You can use the server side (i.e. Apache SSI doc ).

Frames would be the only other way that I can think of that would not require the use of a programming language on the server or client side.

0
source

Source: https://habr.com/ru/post/1302403/


All Articles