5.773 minor bug: openonclick param and top menu item w/ url

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
rybskej
Beginner
Beginner
Posts: 1
Joined: Thu May 17, 2007 8:59 pm

5.773 minor bug: openonclick param and top menu item w/ url

Post by rybskej »

I ran into a small bug when upgrading to 5.773 from 5.762 today:

mmenudom.js throws a javascript error when clicking a top menu item that has "url" property defined, is not a sub-menu, and the top menu has "openonclick=true" defined as a property.


To recreate the bug in the default menu_data.js file from the 5.773 distribution, add:
openonclick=true;

to the menuStyle object definition, and watch for javascript errors when clicking a non-submenu item in the top-level of the menu. You may need to change the target URL to something invalid (that will timeout) to give yourself enough time to see the javascript error before the page location changes.

The error is in mmenudom.js, which is (incorrectly?) calling the function:
function _5($){return eval($)}

after you click on an item that has a URL defined but is not a submenu. The value of the input param "$" is the value of the url param. So, for example, for a menu item:
aI("text=Home;url=http://milonic.com/;");

the _5 function attempts to eval the string "http://milonic.com/", which thows a javascript syntax error while the page is being redirected to that URL. It is functionally non-harmful, in that the user's page does still at least redirect to that URL, but might cause issues depending on what is being eval'ed.

Version 5.762 of the Milonic menu did not have this issue.

A temporary solution I found is to redefine the _5 function as follows:
function _5($){try{return eval($)}catch(e){}}

It is not clear whether or not this solution will cause other issues with the menu system. Thus, it is recommended that for this be correctly fixed, the menu system should prevent the _5 function from being called in the first place when a menu item is clicked to redirect to a new URL, that item is not a sub-menu, and the menu in which the item is located has the "openonclick=true" property defined.
Post Reply