By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,576 Members | 1,399 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,576 IT Pros & Developers. It's quick & easy.

onmouseout not working

P: n/a
Does anyone know why the onmouseout isn't working in the following?
I've just started the script (tho I'm sure I've spent over 40hrs on
this problem alone) and am trying to get just 2 buttons working before
I add the other 4. I'm absolutely mystified by the sticky onmouseout.

I've combined a couple of scripts that I've found in the newsgroup to
accomodate the mouseovers and "active" button action. Only 1 button
can be active at a time.

If you need further info, let me know I'd be happy to furnish. Thanks
in advance for any advice/comments.
Matt
<html>
<head>
<script language="JavaScript">
<!--
var btnstate="down";
image01= new Image(42,42)
image01.src="new2_03.gif"
image02= new Image(42,42)
image02.src="new2_03-over.gif"
image03= new Image(42,42)
image03.src="new2_07.gif"
image04= new Image(42,42)
image04.src="new2_07-over.gif"

function rollover(imagename, newsrc){
document.images[imagename].src=newsrc.src
}

function setAllButtonsUp(btnstate){
//alert(btnstate);
document.example.src='new2_03-over.gif';
document.example2.src='new2_07.gif';
// document.upbutton3.src=new2_11.gif
// document.upbutton4.src=new2_13.gif
// document.upbutton5.src=new2_16.gif
// document.upbutton6.src=new2_19.gif
// document.upbutton7.src=new2_21.gif
}

function setAllButtonsUp2(btnstate){
//alert(btnstate);
document.example.src='new2_03.gif';
document.example2.src='new2_07-over.gif';
// document.upbutton3.src=new2_11.gif
// document.upbutton4.src=new2_13.gif
// document.upbutton5.src=new2_16.gif
// document.upbutton6.src=new2_19.gif
// document.upbutton7.src=new2_21.gif
}

//-->
</script>
</head>

<body>
<a href="#" onmouseover="rollover('example', image02)"
onmouseout="if(btnstate != down')rollover('example', image03)"

onclick="setAllButtonsUp('down');document.example. src='new2_03-over.gif';"><img
src="new2_03.gif" name="example">
</a>
<a href="#" onmouseover="rollover('example2', image04)"
onmouseout="if(btnstate != 'down')rollover('example2', image04)"

onclick="setAllButtonsUp2('up');document.example2. src='new2_07-over.gif';"><img
src="new2_07.gif" name="example2">
</a>
</body>

</html>
Jul 23 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Matt L. wrote:
Does anyone know why the onmouseout isn't working in the following? <snip>
var btnstate="down";
<snip>
onmouseout="if(btnstate != down')rollover('example', image03)"

I didn't see where btnstate was ever set to anything other than 'down'
so the mouseout event never called the rollover function. You'll
probably want to set it to something other than 'down' where
appropriate. If I initialize btnstate to 'up' at the beginning of the
javascript the following work on my ie6:

<a href="#" onMouseOut="if(btnstate!='down'){rollover('example 1',
image03)}"><img src="new2_03.gif" name="example"></a>
<a href="#" onMouseOut="if(btnstate!='down'){rollover('example 2',
image04)}"><img src="new2_03.gif" name="example"></a>

Mike
Jul 23 '05 #2

P: n/a
Lee
Matt L. said:

Does anyone know why the onmouseout isn't working in the following?
I've just started the script (tho I'm sure I've spent over 40hrs on
this problem alone) and am trying to get just 2 buttons working before
I add the other 4. I'm absolutely mystified by the sticky onmouseout. <a href="#" onmouseover="rollover('example', image02)"
onmouseout="if(btnstate != down')rollover('example', image03)"


That missing quote doesn't jump out at you?

Jul 23 '05 #3

P: n/a
Thanks for the tip. I apologize for the sloppy code.

(I've been staring at these lines for several days now trying figure this
out)

In exasperation I must have left it out in my post. Unfortunately, putting
it where it belongs doesn't fix the problem for me.

Do you see anything else that is wrong or out of place?

Appreciate the feedback,
Matt
"Lee" <RE**************@cox.net> wrote in message
news:ci*********@drn.newsguy.com...
Matt L. said:

Does anyone know why the onmouseout isn't working in the following?
I've just started the script (tho I'm sure I've spent over 40hrs on
this problem alone) and am trying to get just 2 buttons working before
I add the other 4. I'm absolutely mystified by the sticky onmouseout.

<a href="#" onmouseover="rollover('example', image02)"
onmouseout="if(btnstate != down')rollover('example', image03)"


That missing quote doesn't jump out at you?

Jul 23 '05 #4

P: n/a
Matt L. wrote:
<snip>
In exasperation I must have left it out in my post. Unfortunately, putting
it where it belongs doesn't fix the problem for me.
Do you see anything else that is wrong or out of place?


Please post all of your code.
Mike
Jul 23 '05 #5

P: n/a
Mike-
See your email....

Matt
"mscir" <ms***@access4less.net> wrote in message
news:10************@corp.supernews.com...
Matt L. wrote:
<snip>
In exasperation I must have left it out in my post. Unfortunately, putting it where it belongs doesn't fix the problem for me.
Do you see anything else that is wrong or out of place?


Please post all of your code.
Mike

Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.