Computing.Net > Forums > Web Development > Javascript Drop Down Menu Help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Javascript Drop Down Menu Help

Reply to Message Icon

Name: Rider3
Date: May 28, 2008 at 14:23:29 Pacific
OS: win xp
CPU/Ram: 1g
Product: custom
Comment:

Hi im experimenting with Javascript for 1st time ever. Knew i wouldnt be able to get away without using it forever.

Having trouble obviously, can anyone tell me whats wrong with this please? im pretty sure my css is write.

<script type="text/javascript">

<!-
var objNavMenu = null;
var prevObjNavMenu = null;
var prevObjDropMenu = null;
var numDropMenu = 7;

var bgLinkColor = '#000';
var bgLinkHover = '#000'
var bgLinkActive = '#900'
var linkColor = '#fff'
var linkHover = '#fff'
var linkActive = '#fff'
var isIE = null;

if(navigator.appName.indexOf('Microsoft Internet Explorer') != -1) isIE=1;

function initDropMenu () {

document.onclick = hideDropMenu;
for (i=1; i<=numDropMenu; i++) {
menuName = 'dropMenu'+ i;
navName = 'navMenu' + i;
objDropMenu =
document.getElementById(menuName);
objNavMenu =
document.getElementById(navName);
objDropMenu.style.visibility =
'hidden';
objNavMenu.onmouseover= showDropMenu;
objNavMenu.onmouseout = menuOut;
objNavMenu.onclick = showDropMenu;
}

objNavMenu = null;
return; }


function showDropMenu(e) {
menuName = 'drop' +
this.id.substring(7,this.id.length);
objDropMenu =
document.getElementById(menuName);

if(prevObjDropMenu == objDropMenu) {
hideDropMenu();
return;
}

if(prevObjDropMenu != null)
hideDropMenu();
objNavMenu =
document.getElementById(this.id);
if ((prevObjNavMenu != objNavMenu) ||
((prevObjDropMenu == null)) {
objNavMenu.style.color = linkActive;
objNavMenu.style.backgroundColor =
bgLinkActive;
}

if (objDropMenu) {
xPos = objNavMenu.offsetParent.offsetLeft+objNavMenu.offsetLeft;
yPos = objNavMenu.offSetParent.offsetTop+objNavMenu.offsetParent.offsetHeight;

if (isIE){
yPos -= 1;
xPos -= 6;
}

objDropMenu.style.left = xPos + 'px';
objDropMenu.style.top = yPos +'px';
objDropMenu.style.visibility = 'visible';

prevObjDropMenu = objDropMenu;
prevObjNavMenu = objNavMenu;
}
;}

function hideDropMenu(){
document.onclick = null;

if (prevObjDropMenu) {
prevObjDropMenu.style.visibilty = 'hidden';
prevObjDropMenu = null;
prevObjNavMenu.style.color = linkColor;
prevObjNavMenu.style.backgroundColor = bgLinkColor;
}

objNavMenu = null; }

window.onload=initDropMenu;

// -->
</script>



Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: May 28, 2008 at 16:49:57 Pacific
Reply:

Please state what you are trying to accomplish with the above script, what it is doing that you don't want it to do or what it is not doing that you want it to do.

Also, would you please provide a link to a page where you have tried to implement the above code? It's much easier to debug javscript with it in a page how it would be used.

Michael J


0

Response Number 2
Name: Rider3
Date: May 29, 2008 at 04:13:04 Pacific
Reply:

Thanks Michael J

But i decided to just stick with a plain and simple navigation bar.

Thanks Anyway.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: Javascript Drop Down Menu Help

program for drop down menu www.computing.net/answers/webdevel/program-for-drop-down-menu/2442.html

drop down menu database link www.computing.net/answers/webdevel/drop-down-menu-database-link/1447.html

Drop down menu www.computing.net/answers/webdevel/drop-down-menu/1213.html