View Full Version : onMouseOver, onMouseOut...

Shirk Deio
Mar 23rd, 2007, 11:14 PM
I'm working on a code for my website that on the mouseOver event, a menu pops up to the right. I have successfully used the code I copied from a website (www.dynamicdrive.com), but I'm trying to add that the image changes on the MouseOver event, as well (eg. onMouseover, menu pops up and image changes).

The code I copied uses the function dropdownmenu(obj, e, menucontents, menuwidth) to create the menu onMouseOver, and the function delayhidemenu() to remove it.

Here's the code I was trying to use for this:

<script type="text/javascript">
function mouseOver(me)
me.src = "URL for MouseOver"
dropdownmenu(me, event, menu1, '165 px')
function mouseOut(me)
me.src ="URL for MouseOut"

That placed in the head of the HTML page, then I placed this in the body for the image:

<a href="MY SITE" onMouseOver="mouseOver(this)"
onMouseOut="mouseOut(this)"><img src="MY IMG" border=0 name="home">

But this won't work. Please let me know what I did wrong and how I should fix it.


Arty Effem
Mar 24th, 2007, 03:59 AM
<a href="MY SITE" onMouseOver="mouseOver(this)"

You are passing mouseOver a reference to the link, not the image that it encloses. Assign the function to the onmouseover event of the image instead.