homepage Welcome to WebmasterWorld Guest from 54.211.213.10
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
JavaScript Menu Help
Problems putting a drop down menu into a .js file
geebus




msg:1470834
 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




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

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




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved