Welcome to WebmasterWorld Guest from 54.147.44.93

Forum Moderators: open

Message Too Old, No Replies

JavaScript Menu Help

Problems putting a drop down menu into a .js file

     

geebus

12:02 am on Dec 10, 2003 (gmt 0)



I have been developing a drop down menu using CSS and JavaScript and I want to move it from the .html file to a .js that can be appended to every page in my website. When I comment the menu in the body and try using the .js file, the menu does not appear. I must be doing something wrong with the .js file but I am too inexperienced and I have no idea what. I will post the code below:

// JavaScript Document
function showMenu()
{
var HTML = "";
HTML += "<table class = 'Body'> ";
HTML += "<tr> ";
HTML +="<td class='header' colspan='100'><div class='center'><img src='Images/banner.jpg'/></div> </td>";
HTML += "</tr>";
HTML += "<tr>";
HTML +="<td class='menu'>";
HTML += "<div id = 'ProductMenu'>";
HTML +="<ul>";
HTML +="<li>";
HTML +="<a class='menu' href = '#'>";
HTML +="Routers</a>";
HTML +=</li><br/>
HTML +="<li>";
HTML +="<a class='menu' href = '#'>";
HTML +="Network Cards";
HTML +="</a>";
HTML +="</li><br/>";
HTML +="<li>";
HTML += "<a class='menu' href='#'>";
HTML +="Cables</a>";
HTML +="</li>";
HTML +="</ul>";
HTML += "</div>";
HTML += "<a class='menu' href ="#" onClick=";
HTML += "showLayer('ProductMenu');";
HTML += "onDblClick=";
HTML += "hideLayer('ProductMenu');";
HTML += "> Products</a>";
HTML +="</td>";
HTML +="<td class ='menu'><div id = 'ServicesMenu'>";
HTML +="<ul>";
HTML +="<li>";
HTML +="<a class='menu' href = '#'>";
HTML +="Installation</a>";
HTML +="</li><br/>";
HTML +="<li>";
HTML +="<a class='menu' href = '#'>";
HTML +="Appointment";
HTML +="</a>";
HTML +="</li><br/>";
HTML +="<li>";
HTML +="<a class='menu' href='#'>";
HTML +="Emergency</a>";
HTML +="</li>";
HTML +="</ul>";
HTML += "</div>";
HTML += "<a class='menu' href ='#' onClick=";
HTML += "showLayer('ServicesMenu');";
HTML += "onDblClick=";
HTML += "hideLayer('ServicesMenu');">;
HTML += "Services</a></td>";
HTML +="<td class = 'menu'><a class='menu' href = 'Main.html'>Home</a></td>";
HTML += "<td class = 'menu'>&nbsp;</td>";
HTML +="<td class = 'menu'>&nbsp;</td>";
HTML += "</tr>";
HTML +="</table>";
document.write(HTML);
}

Well any help will be appreciated and thanks in advance.

Sincerely,
geebus

HocusPocus

12:24 am on Dec 10, 2003 (gmt 0)

10+ Year Member



I think if you didn't have the code in a function the script would output.

Does anyone know why javascript doesn't write when called from a function?

BlobFisk

3:08 pm on Dec 10, 2003 (gmt 0)

WebmasterWorld Senior Member blobfisk is a WebmasterWorld Top Contributor of All Time 10+ Year Member



It might be a better idea to use an SSI (Server Side Include). JS is probably not the best way to achieve this...
 

Featured Threads

Hot Threads This Week

Hot Threads This Month