2 different functions on mouseOver event?

Hi Everyone,

I’m having trouble with a bit of JavaScript. Does anyone know if it is possible to have 2 functions execute on a mouseOver event?

For example, on my mouseOver, I want to have an image flip and I want to call another function that does something else.

I tried comma and semi separated, but that doesn’t seem to do it.

Maybe I could write one function that calls the other 2??

HELP!! Any ideas would be appreciated!!



Heres somthing similar to what your after, it does a rollover and display a message in a table.

<script LANGUAGE=“JavaScript”>


    // load up all the rollovers
    blankmsg = new Image();
    blankmsg.src = "images/blank_msg2.gif";

    about0 = new Image();
    about0.src = "images/aboutbuttonred.gif";
    about1 = new Image();
    about1.src = "images/aboutbuttonyel.gif";
    aboutmsg = new Image();
    aboutmsg.src = "images/aboutro.gif";

loadedImages = 1;

    function doRollover (theButton, state) {
            if (document.images && loadedImages && ( document[theButton] )) {
                    document[theButton].src = eval (theButton + state + ".src");
                    (state) ?
                            document['msgArea'].src = eval (theButton + "msg.src"):
                            document['msgArea'].src = blankmsg.src;



<a href=“about.htm” onMouseOver=“doRollover(‘about’,1)” onMouseOut=“doRollover(‘about’,0)”><img name=“about” src=“images/aboutbuttonred.gif” alt=“About” width=“223” height=“34” border=“0”></a>

<!-- This is the part of the table with the message appears in, Note the img tag //–>

<td valign=“top” align=“left” width=“213”><img name=“msgArea” src=“images/blank_msg2.gif” height=“169”></td>

Hope this helps you a bit or atleast points you in the right direction. :wink:

Thanks Big Al.

I’ll see if I can use that to get me started!

Appreciate it.


Separating the two calls by a semicolon should work:


If this doesn’t work, post your code so we can see the cause.

HI, i posted a similar question a few days ago and i got my answer. but i actually found a shorter way. here are teh two events i wanted to combine:


instead of going through my documents and practically rewriting it all, heres how i fixed it:

onMouseOver="imgover(pic1), changetext(content[0])"

at first i tried doing this:


adn this also:


i hope this short method works for you like it did for me.

Hey JamJammo et all,

Actually, this shouldn’t work:

onMouseOver="imgover(pic1), changetext(content[0])"

But rather it should be:

onMouseOver="imgover(pic1); changetext(content[0])"

I think Kevin (kyank) already explained this answer.

aDog :cool:

onMouseOver="imgover(pic1); changetext(content[0])"

Is the way it should work, if it does not then make sure each of the functions called returns a value at the end of it’s execution else it may stop it from executing the second function.

oh yeah,

oops. i meant ‘;’ not ‘,’

thanks for the correction.
but it actually IS working with the comma and it DOESNT work with the semicolon.

aint it weird?