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>
4
  • 2
    Try <iframe src="menu.html"></iframe> instead. Commented Mar 12, 2012 at 12:03
  • 1
    If you use the iframe tag, don't forget to add a width and height. Commented Mar 12, 2012 at 12:05
  • 1
    Better use a dynamic language for web like php. I suggest this tutorial tutorialzine.com/2011/08/jquery-mobile-mvc-website-part-2 Commented Mar 12, 2012 at 12:05
  • Solution available here: stackoverflow.com/questions/39447411/… Commented Sep 12, 2016 at 17:10

5 Answers 5

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.

Sign up to request clarification or add additional context in comments.

Comments

0

Try specifying the column width as described here.

<frameset cols="100%">
  <frameset rows="200, *">

Comments

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.

Comments

0

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

Example:

jQuery:

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

HTML:

<div id="menu">
</div>

Comments

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.