Include one HTML file in another HTML file using server side include
How can I include an HTML file in another HT开发者_JS百科ML file. Is there any simple way to do that?
Thanks
I think you're looking for server side includes: http://en.wikipedia.org/wiki/Server_Side_Includes. To summarize (and oversimplify) change the extension of your page from .html page to .shtml, then you should be able to use an include statement similar to:
<!--#include virtual="somefile.html" -->
You might be looking for information on 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>
Are you serving the HTML files from a web server like IIS or Apache? Both support server-side includes:
<!--#include virtual="nameOfFileToInclude.html" -->
A page at the WWW FAQs explains.
Well if you have any server-side scripting language available all will perform fine at this task. Another option would be html-frames (in your case most likely an iframe), or ajax (asynchrounus javascript request).
My preferred method employs PHP, if that is installed on your server. If so, the simplest way to do it is just insert this code at the appropriate place in your containing file: <?php include('filename.php') ?>
Note that both files must have the extension .php
.
You could use server side includes (ie. Apache SSI doc).
Frames would be the only other way I can think of which would not require the usage of a programming language on either the server or client side.
精彩评论