...

View Full Version : Disable onMouseOut when image is clicked



cubism
08-05-2002, 05:07 PM
I have an image rollover, and I want to disable the onMouseOut behavior if onClick is true (in other words, if the user clicks an image, when the mouse moves out it doesn't switch the highlighted button back to dim).
The page in question is here:
http://hebelergraphics.com/logos/index.html
The client wanted all images to be on one page, so making multiple pages for each image, while it would solve the problem, isn't an option. Notice how when the buttons on the left are rolled over, they highlight, when rolled out, they dim. When one is clicked, it changes the image in the center; it should stay highlighted when the mouse rolls out.
I'm guessing there's an if/then statement that needs to be written, like "If the image is clicked, change all other images to the up state and don't do anything onMouseOut to the current image". Any suggestions as to how to write something like this?
Thanks.

Mr J
08-05-2002, 07:49 PM
Take a look on my site at

www.huntingground.freeserve.co.uk/webplus/buttons/butcell.htm

Select the link for [B]Text Links[B ]and look for:

Highlighted Link on

This might be the script you require.

beetle
08-05-2002, 11:06 PM
Just use a separate array to keep track of which images have been clicked, and check against that array whenever an onMouseOut() occurs...

adios
08-05-2002, 11:08 PM
OK, listen up.....

Add this to the script:

function unhilite(exception) {
for (var i=1; i<9; ++i)
if (i != exception) chgImg('image' + i + 'preview','thumb' + i + 'u')
}

document.clicked = null;

Do the HTML like so:

<td align="center">
<a href="#" onClick="document.clicked=this;
chgImg('left','left1');chgImg('right','right1');
unhilite(1);return false;"
onmouseover="chgImg('image1preview','thumb1o')"
onmouseout="if(document.clicked!=this)chgImg('image1preview','thumb1u')">
<img name="image1preview" border="0" src="image1preview.jpg" width="45" height="45"></a></td>
</tr><tr>
<td align="center">
<a href="#" onClick="document.clicked=this;
chgImg('left','left2');chgImg('right','right2');
unhilite(2);return false;"
onmouseover="chgImg('image2preview','thumb2o')"
onmouseout="if(document.clicked!=this)chgImg('image2preview','thumb2u')">
<img name="image2preview" border="0" src="image2preview-light.jpg" width="45" height="45"></a></td>

...and so on. The document&#46;clicked property (custom) tracks the link that lit the current image; it's tested to see if the mouseout should run. return false; to cancel any side-effects of the link. Hope that works.

beetle
08-05-2002, 11:17 PM
Uhhh...wow. That sure looks complicated. I think a tracking array would be a bit easier. Oh, and can you please post your code within the vB Code 'CODE' tags?

adios
08-05-2002, 11:19 PM
Pardon me but - who the heck are you? This isn't your website, and some of us have been here a bit longer than you.

Scratch that - all of us have been here longer. :rolleyes:

beetle
08-05-2002, 11:28 PM
Wow. I thought I made a plain comment and asked a simple question. I even said 'please' (besides, what's wrong with a little controversy?)

I've been on/visited MANY different web development forums and it always seems typical and proper (and many times expected by the MODs) to post large amounts of code into the proper 'CODE' tags. Just FYI.

Also...the number of posts I have made at this particular forum (or any for that matter) gives you ZERO insight to my knowledge or experience. Certainly you don't think your 178 posts here gives you some sort of intangible seniority over me or anyone else's post content and the right to be rude, do you?

Look, apologies all around for misread intentions. Lighten up. It's really not that bad.

cubism
08-06-2002, 04:01 AM
Thanks, I'm going to give it a whirl...
FWIW, this has been an excellent first-post experience in a new community, what with both valuable info and squabbling rolled into one thread. I'm stoked!

cubism
08-06-2002, 04:22 AM
Adios-you rock!!!!! Take a look now, the code you gave me does the trick. Thanks, I owe you...

vorl
07-25-2005, 05:12 PM
Hi

Sorry for restarting a old thread but I really need help on this script.
I was wondering if u could help me to possibly edit the script so I can have a image for the initial state, onmouseover and when clicked. Also is it possible to select a image initially when the page is loaded?

Thanks for any help!!

vorl

vorl
07-26-2005, 08:56 PM
hi again

please can some1 help me on this as its the only script I have found which is similiar to what i need!!

thanks, any help appreciated

vorl



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum