Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:10

ERROR: '24' is null or not an object


Poster: akirk
Dated: Monday September 13 2004 - 17:38:41 BST

I have written a menu, :?: which from the log works, but when it is being run, I get this error:
Line: 98
Error: '24' is null or not an object

When I choose to debug, it points to the following line in mmenudom.js:

function _drawMenu(_mnu){_mnucnt++;var _M=_m[_mnu];_top="";_left="";if(!_M[24]&&!_M[8]){_top="top:-999px";_left="left:-999px"}if(_M[2]!=null){if(!isNaN(_M[2]))_top="top:"+_M[2]+"px"}if(_M[3]!=null){if(!isNaN(_M[3]))_left="left:"+_M[3]+"px"}_mnuHeight="";if(_M[12]=="horizontal"){_M[12]=1;horiz=1;if(_M[28]){_mnuHeight="height="+_M[28]}}else{_M[12]=0;horiz=0}_visi="hidden";_mt="";_nw="";_tablewidth="";if(_M[4]){_tablewidth="width="+_M[4];if(op7&&!IEDtD)_tablewidth="width="+(_M[4]-(_M[20]*2)-(_M[5]*2))}else{_nw="nowrap"}_ofb="";if(_M[7].offbgcolor)_ofb="background:"+_M[7].offbgcolor;_brd="";if(_M[5]||_M[7].borderwidth){_brdsty="solid";if(_M[7].borderstyle)_brdsty=_M[7].borderstyle;if(_M[10])_brdsty=_M[10];_brdcol="#000000";if(_M[7].bordercolor)_brdcol=_M[7].bordercolor;if(_M[17])_brdcol=_M[17];if(_M[7].borderwidth)_brdwid=_M[7].borderwidth;if(_M[5])_brdwid=_M[5];_brd="border:"+_brdwid+"px "+_brdsty+" "+_brdcol+";"}_ns6ev="";if(_M[23]=="scroll"&&ns6&&!ns7)_ns6ev="onmousemove=\"getEVT(event,"+_mnu+")\"";_bgimg="";if(_M[18])_bgimg=";background-image:url("+_M[18]+");";_posi="absolute";if(_M[24])_posi=_M[24];if(_M[4]&&!_M[23])_posi+=";width:"+_M[4]+"px";_padd="";if(_M[20])_padd="padding:"+_M[20]+"px;";_wid="";if(_M[24]=="relative"){if(!_M[4])_wid="width:1px;";_top="";_left=""}if(mac&&_wid=="")_wid="width:1px";_cls="mmenu";if(_M[7].offclass)_cls=_M[7].offclass;_mt+="<div id=shadow"+_mnu+" style=\"position:absolute\"></div>";_mt+="<div class="+_cls+" onselectstart=\"return false\" "+_ns6ev+" onmouseover=\"clearTimeout(_MT)\" onmouseout=\"_CAMs()\" id=menu"+_mnu+" style=\""+_padd+_ofb+";"+_brd+_wid+"z-index:99;visibility:"+_visi+";position:"+_posi+";"+_top+";"+_left+_bgimg+"\">";_mt+="<table "+_mnuHeight+" "+_tablewidth+" id=tbl"+_mnu+" border=0 cellpadding=0 cellspacing=0 >";for(_b=0;_b<_M[0].length;_b++){drawItem(_b);_el++}if(mac)_mt+="<tr><td id=btm"+_mnu+"></td></tr>";_mt+="</tr></table>";_mt+="</div>";_d.write(_mt);if(_M[8]){_M[22]=gmobj("menu"+_mnu);if(ie55)drawiF(_mnu)}else{if(ie55&&_ifc<_mDepth)drawiF(_mnu);_ifc++}if(_M[29]){_M[29]=_M[29].toString();_fs=_M[29].split(",");if(!_fs[1])_fs[1]=50;if(!_fs[2])_fs[2]=2;_M[29]=_fs[0];followScroll(_mnu,_fs[1],_fs[2])}if(_mnu==_m.length-1){clearTimeout(_mst);_mst=setTimeout("_MScan()",150);_getCurPath()}}


Does anyone know how to get around this error and get the browser to recognize this milonic-written functionality? :?:

Thanks!

Re: ERROR: '24' is null or not an object


Poster: kevin3442
Dated: Monday September 13 2004 - 18:49:35 BST

Hi,

akirk wrote:
...Does anyone know how to get around this error and get the browser to recognize this milonic-written functionality? :?:

It's a common misconception that if an error message points to a line of code in one of the menu source files (milonic_src.js, mmenudom.js, mmenuns4.js) then it necessarily means that there is an error in the indicated file. That's usually not the case. For instance, in this particular case, the 24 is simply an index into the menu array; it's just an explicit integer, so it can't be null or not an object.

What is usually the case is that there is a problem in the code that defines the menus (e.g., in menu_data.js, or some inline javascript). This makes sense upon further consideration... First, all of us use the same mmenudom.js file (slightly different versions), but we each have different menu_data code, so errors are more likely in the different menu_data.js code. Second, the base javascript source (mmenudom.js, milonic_src.js) is used to parse and process what you put into menu_data.js. So, if there's an error in menu_data.js, it will cause the parser to fail, often producing an error message pointing to mmenudom.js or one of the other files.

Hope that made sense (I was a little more detailed so that I could refer to this message in future posts).

The upshot is that we'll need to see either (1) the page itself where the menu is failing (can you post a url?), or if you can't post a url, (2) the full code from your menu_data.js.

Cheers,

Kevin


Poster: akirk
Dated: Monday September 13 2004 - 19:23:23 BST

Kevin,

Thanks for the tip. You said that the integer cannot be null, and I realized that one element of my array was null, and it was throwing that error, because this position was null. I changed it to manually populate a value in this position, but not print out, and it worked without error.

Thanks again! :D


Poster: kevin3442
Dated: Monday September 13 2004 - 19:53:21 BST

akirk wrote:
Kevin, Thanks for the tip.

You're welcome.

akirk wrote:
You said that the integer cannot be null, and I realized that one element of my array was null, and it was throwing that error, because this position was null.

Ah so... it is of course true by definition that an explicit integer, like 24, cannot be null. But the array element that the integer indexes certainly can be null. So, the error message:
akirk wrote:
Error: '24' is null or not an object

doesn't realy make sense, unless "24" was the name of a variable, which also isn't possible. On the other hand, had the message said, Error: '_M[24]' is null or not an object then it would've been a different story... the element of the array being null in that case. It sounds like you were running IE. I find javascript error messages generally fakey, and (to me at least) they seem the flakiest in IE.

Makes me wonder if you had a menu where the menuheight property was set to null?

akirk wrote:
... I changed it to manually populate a value in this position, but not print out, and it worked without error.

And of course... that's the main thing! Glad you got it working.

Cheers,

Kevin


Poster: akirk
Dated: Monday September 13 2004 - 20:00:33 BST

Yes, I was running IE so maybe that was the quirk. I did not have the menuheight set at all. I realized that I was dynamically creating new menus for the drop-downs and the menu item one of the menus was referring to was null. Once I set it to some string, it worked.


Yeah! :D