DHTML Menu Studio FAQ

Question ID:
Q3009
Question:
When I combine the menu with other JavaScript code on a single page, either the menu or the other script-driven coponent doesn't work. How do I fix this?
 
This is most likely caused by duplicate onLoad event handlers. Menu generated by DHTML Menu Studio as well as the other script-driven component need this handler to work correctly. To fix the problem, you need to make sure both onLoad handlers get executed. Please note that (starting with v2.5 of DMS) the menu's onLoad handler automatically detects any previously established onLoad handler and calls its internally. The only possibility this problem can occur is when another code sets the onLoad handler AFTER the code for the menu. In such case, please follow the instructions below.
First, you need to locate the custom event handler call (the one which comes from the other script-driven component). This is most likely placed in the tag or inside script code, e.g. window.onload='[handler_function]'. Once you locate this handler, remove it. Now, add the following code anywhere in the body section of your web page:
<script language='JavaScript'>
<!--
addLoadHandler ('[handler_function]');
//-->
</script>
Please make sure you replace [handler_function] with the name of the other handler function in the above code.

Below is an example:

<script language='JavaScript'>
<!--
function xyz()
{
alert ('this will be displayed when the page is loaded');
}

addLoadHandler ('xyz');
//-->
</script>
Here's another (very frequent) example:
The body tag has an onload handler calling preloadImages:
<body onload="preloadImages();">

You'll need to change this to:
<body>

Then add the following code e.g. at the bottom of the page:
<script language='JavaScript'>
addLoadHandler ('preloadImages');
</script>

If the onLoadHandler uses parameters, e.g. onLoad="preloadImages('xyz')", you'll need to create a separate function, that is:
function myHandler()
{
	preloadImages('xyz');
}
addLoadHandler ('myHandler');