How to Insert HTML from another file
I have a website, and I want to insert the HTML from another file into the web page each time the page loads.
for example, if I had a file called index.html, and another file called header.html, how can I have index.html insert the code from header.html each time the page is loaded?
I tried looking for a javascript function that can read and insert a file off the server, but I couldn't find anything.
Thanks for any help you can provide.
Megan posted this at 18:09 — 19th September 2007.
She has: 11,421 posts
Joined: Jun 1999
You have a few options here. You can use Server Side Includes (SSI) or php Includes (or another server side language, depending on what's installed on your server). Try to find out if your hosting account has php support - if it does, use PHP includes. It's just as easy as SSI and your pages will already be in php format if you want to add on any extra functionality.
To learn how to use these includes, just do a search for "Server Side Includes" and "PHP include".
Megan
Connect with us on Facebook!
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.