Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help understanding JavaScript Errors.

Status
Not open for further replies.

milams

Programmer
May 28, 2004
32
US
Hi,

I am running a script on CSS Menu and in Netscape and Internet Explorer it's coming up with an error saying "objDropMenu has no properties" line 23(objDropMenu.style.visibility = 'hidden';). Can someone tell me what that means? I can't seem to see the Syntax error, but there is one right? I would appreciat any help. Here is the fist 27 lines of code. It says the error occurs on line 23.

var objNavMenu = null;
var prevObjNavMenu = null;
var prevObjDropMenu = null;
var numDropMenu = 7;
////// link styles
var bgLinkColor = '#F0D79F';
var bgLinkHover = '#000000'
var bgLinkActive = '#000000'
var linkColor = '#000000'
var linkHover = '#F0D79F'
var linkActive = '#F0D79F'

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;
}
 
The error, in your case, probably means that objDropMenu is referring to an element that doesn't exist - so either it hasn't loaded at the time you're calling the script, or there is no element with an ID of " 'dropMenu' + i ".

Put an alert in to see what 'menuName' is right before the error, then make sure you have an element with that ID.

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top