tags:

views:

242

answers:

6

I am new to HTML. I have an html page named "main.html" and i want to include another html page called "menu.html" in it. My main.html page doesn't include frames and it is designed using div tags. My site is hosted on linux based server The site I have to redesign is Java questions.

+1  A: 

Check out server side includes.

Richard
i guess your are talking about <include virtual="menu.shtml" > something like this i did but it didnt work :-(
harshit
The details of the syntax depend on your server. And then may need to be enabled. To help more you will need to expand the question with more details about your environment.
Richard
+9  A: 

You want to look at Server Side Includes (SSI). This tutorial by Apache should get you up and running if that site is running on Apache.

There are plenty of Server Side ways of doing this, but all except SSI require the use of a language other than HTML.

If you're using IIS, you can check out Microsoft's writeup on Server Side Includes.

George Stocker
do i need to include .shtml file for it or is .html fine
harshit
my site is not running on apache what else could be the way
harshit
Is it running on IIS?
George Stocker
You'd have to give the files a .shtml extension.
George Stocker
my site is hosted on linux web based server
harshit
Then they're probably using Apache as the web server. You need to find out which web server you're running. There are two major ones, Apache and IIS. Apache runs on all platforms, but IIS (afaik) only runs on Windows.
George Stocker
thanks Gortok for prompt replies. it has worked..
harshit
+1  A: 

You should use server-side includes. i.e. in jsp you can use: <c:import url="/include/navigation.jsp" />, in php <?php include("/sidebar.php");?> and so on. This is the good way to do what you need: include a navigation menu, or other parts common to all pages, without rewriting it in each page. You can also do the same in other ways (with some javascript i.e.) but I doubt that you want to build a site called Java Questions without any server side language.

alexmeia
A: 

You can make an ajax call in javascript if you want to avoid using the server.

In JQuery you would do:

<div id="putStuffHere">


</div>
<script>
$('#putStuffHere').load('myStuff.html');
</script>
Nick
A: 

Or use PHP for the future :)

Tobiask
+1  A: 

I think that PHP is the easiest way to do this. Most of the time you can just change your main.html file to main.php then add this php code where you want the menu bar:

<?php include('menu.html'); ?>

And that's it! You have to make sure that php is installed on your sever. Also this will ONLY work on a server. So if you are testing on your computer and using something like dreamweaver (or even a browser), you won't see anything until it's online.

Tylor