Link to home
Start Free TrialLog in
Avatar of gamebits
gamebitsFlag for Canada

asked on

Dropdown menu all open on page load

I have a very simple script on my webpage for a dropdown menu, it works great but the problem is when a load the page everything is open, it will close as soon as I go over but it is anoying.
onmouseover="mopen('m1')"
        onmouseout="mclosetime()">Tools</a>
        <div id="m1"
            onmouseover="mcancelclosetime()"
            onmouseout="mclosetime()">

Open in new window

<script type="text/javascript">
// Copyright 2006-2007 javascript-array.com


var timeout	= 200;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose;
</script>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of TRW-Consulting
TRW-Consulting
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gamebits

ASKER

There was something else on my page that cause the problem, working now.

Thanks
No need to award points, then - just post the solution and close the question.