I’m making a web application, and I have to make a menu that is repeated on multiple pages. But every time I make a change in any menu I have to edit all pages. Javascript may create a menu something like this (this is an occurrence):
var divMenu = document.getElementById( "menu" );
//create element <ul> to add to div menu.
var ulMenu = document.createElement("ul");
ulMenu.value =
"<ul id='nav'>"
+ "<li class='current'><a href='/sytematic_inventory/views/administrador/index.jsp'>Inicio</a></li>"
+ "<li><a href=''>Inventarios</a></li> "
+ "</ul>";
divMenu.appendChild( ulMenu );
How is this possible?
Create a remote .js file and do something along the lines of the following:
Demo: http://jsfiddle.net/sDbff/3/
Then, in any page you’d like to include this, drop in a reference to it: