1

I'm trying to make a HTML page (lets say index.html) that will have a dynamic drop down menu. What i want to do is to keep my dropdown menu in a seperate html file(menu.html) so that it will be easier to maintian. What i want to know is that how to load the menu.html file within the index.html file?

I have tried with some frame examples but the menu.html file which contains the DD menu doesnot appear in the index page.

Like for example, I have tried with this in my index page but nothing appears:

<frameset rows="200,*" frameborder="0" border="0" framespacing="0">
<frame src="menu.html" marginheight="0" marginwidth="0" scrolling="auto" noresize>
fara
  • 49
  • 1
  • 7

5 Answers5

1

If you want to stay in HTML, uses : <iframe src="menu.html" width=400 height=200></iframe> with the width and height you want.

But the best is to use PHP by including the file like this :
<?php include('menu.html'); ?>

But it is your choice at the end.

ChapMic
  • 26,954
  • 1
  • 21
  • 20
0

Using jQuery you can handle it

<html> 
  <head> 
    <script src="jquery.js"></script> 
    <script> 
    $(function(){
      $("#divId").load("b.html"); 
    });
    </script> 
  </head> 

  <body> 
     <div id="divId"></div>
  </body> 
</html>
0

Try specifying the column width as described here.

<frameset cols="100%">
  <frameset rows="200, *">
T. Junghans
  • 11,385
  • 7
  • 52
  • 75
0

If you use php you can simply include it. here is a link to a tutorial to show you how to do this tutorial. If you don't use php then ignore this answer, but far better this than frames which have a lot of restrictions on how the content might be shown.

pengibot
  • 1,492
  • 3
  • 15
  • 35
0

You can use jQuery and the .load() function for this purpose.

Example:

jQuery:

$(function() {
    $("#menu").load("menu.html");
});

HTML:

<div id="menu">
</div>
Rupo
  • 402
  • 3
  • 8