...

View Full Version : include .html file in document.write



vilhelm
05-18-2012, 09:26 PM
Hi! how do I include .html files inside a document.write()?

Like document.write('include top.html' "hello!" 'include bottom.html') or something.

I searched for it, and found this:

<!--#include file="top.html" -->

But it doesn't work for me. What is wrong?

I would be very happy if someone could help me :)

felgall
05-18-2012, 10:23 PM
But it doesn't work for me. What is wrong?

It doesn't work for anyone as JavaScript can't access files that way.

See http://javascriptexample.net/ajax.php for a series of examples of how JavaScript can read files from the server.

If you want to use that include statement then you have to have Server Side Includes turned on on your server and serve the pages using an extension that parses them through that module - usually using .shtml instead of .html

If you use the include statement then it goes directly in the HTML and not in any JavaScript.

whypro
05-19-2012, 02:36 AM
You can't do this but you can include an javascript file in your html file and in your another javascript file which will output your HTML file.

felgall
05-19-2012, 03:26 AM
You can't do this but you can include an javascript file in your html file and in your another javascript file which will output your HTML file.

That makes no sense.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum