4 replies [Last post]
buffy28
Offline
newbie
glasgow
Last seen: 16 years 14 weeks ago
glasgow
Joined: 2005-03-17
Posts: 6
Points: 0

hi there
i'm trying to call the js for the menu from a separate file but when i set all this up the second level menu isn't showing on rollover. The main menu is working fine though...
The code i'm using in my html page is:

<SCRIPT LANGUAGE="JavaScript" SRC="a/scripts/lsc.js TYPE="text/javascript"></SCRIPT>

<body onload= function()>

and the js file contains the javascript code for the menu...

activateMenu = function(menu) {

/* currentStyle restricts the Javascript to IE only */
if(document.all && document.getElementById(menu).currentStyle) {
var navroot = document.getElementById(menu);

/* Get all the list items within the menu */
var lis=navroot.getElementsByTagName("LI");
for (i=0; i<lis.length; i++) {

/* If the LI has another menu level */
if(lis[i].lastChild.tagName=="UL"){

/* assign the function to the LI */
lis[i].onmouseover=function() {

/* display the inner menu */
this.lastChild.style.display="block";
}
lis[i].onmouseout=function() {
this.lastChild.style.display="none";
}
}
}
}
}
window.onload= function(){

activateMenu('menu');

}

any ideas on this problem guys?

Tags:
Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 6 years 24 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

calling menu js from separate file

Ally, This is a forum for the discussion of CSS matters; this is a question relating to JavaScript .

If you want to ask questions relating to topics other than CSS can you please post them in 'Off Topic'

Thankyou.

I'll move this thread for you. I'm sure that someone will come along shortly that can help you with this.

Hugo.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

buffy28
Offline
newbie
glasgow
Last seen: 16 years 14 weeks ago
glasgow
Joined: 2005-03-17
Posts: 6
Points: 0

wrong area

sorry! doh... having a blonde moment there... thanks!

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 1 day 4 hours ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5343
Points: 2964

calling menu js from separate file

Hi buffy28,
Can you post a link to an example.
There could be a number of things causing the problem, without seeing the page it's really hard to guess.

ui_dzyner
ui_dzyner's picture
Offline
Regular
india
Last seen: 16 years 13 weeks ago
india
Joined: 2005-03-21
Posts: 29
Points: 0

&quot;&quot; should b closed

SRC="a/scripts/lsc.js

" is not closed
SRC="a/scripts/lsc.js " -- should use this instead--------------

sorry if not correct, just thought it might b the reason