I used the script

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

to include a .html file into another .html file, but for some reason does not show up.

Any reason as to why?

I will be using WAMP and LAMP.

Thanks Jean

+6  A: 

This is using server-side includes. You need to set it up on your server. Despite the misleading "comment" syntax, it really has nothing to do with HTML.

Matthew Flaschen
give me an option without server setup
@Jean good luck with that :P
Chris T
Jean, you *could* read the comment nodes from the HTML DOM, then issue AJAX requests to load the content. But that way madness lies.
Matthew Flaschen
+3  A: 

if there's php on the server you can just include the html file like so

<?php include "donate.html"; ?>

A lamp stack has php so you should be set.

However, the server may not be set up to run the file through php's interpreter. You can either set it to parse whatever the extension of the file is (being the file that is doing the including) or change it to something that is already set to be parsed (home.html -> home.php)

yes i am aware, but I require .html into .html
Well then you need to set up apache to interpret html files through php or copy and paste.Another strategy could be to keep .php files on the server, but use .html links and use mod_rewrite to rewrite *.html to *.php seamlessly and on the fly.

Perhaps the problem is the use of virtual

The file parameter defines the included file as relative to the document path; the virtual parameter defines the included file as relative to the document root.

tried file and virtual nothing seems to be working
@Jean: what do you see when you view the source code from your browser? If you see `<!--#include... -->` then your server hasn't been set up to run the SSIs.
@nickf I want to include this .html file from one domain to other, turning on ssi is something I dont want.I tried a document.write from a .js does not work though
@Jean Use php: `<?php echo file_get_contents(''); ?>`
<object data="file.html" width=400 height=200"></object>

If memory serves... I recall some border issues in IE but that should be sufficient for a primitive integration.

A: is the answer

// jsfile.js

var variable=""+


*include .js file in html*

thats it

Um, no. That does absolutely nothing.
Michael Borgwardt
well it works for me perfectly...and why the down votes
Probably because what you said isn't including a html file within another html file. Which in your question you asked for.
+1  A: 

As your using wamp/lamp I found something that will work:

creating a .htaccess file and put the following in it

Options FollowSymLinks Includes ExecCGI

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml 

Then change your html file extensions to .shtml (including the file that is to include a file)


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

Would become

<!--#include virtual="dontate.shtml" -->

This should work


The the file is in the same directory as the file that is including it use:

<!--#include file="dontate.shtml" -->

If it is in a different directory use:

<!--#include virtual="folder/to/file/dontate.shtml" -->

As per the HTML spec, the only way to do this without server side scripting or server side includes is via iframes.

* note the bolded 'only'.