Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Stopping an 'OnMouseOut' event


Message #1 by "Laphan" <laphan@u...> on Tue, 7 Nov 2000 20:43:29 -0000
Dear Bruce

Many thanks for your advice, this has done the task perfectly.

Rgds

Laphan

----- Original Message -----
From: Bruce Allen <BAllen@e...>
To: javascript <javascript@p...>
Sent: 08 November 2000 18:12
Subject: [javascript] RE: Stopping an 'OnMouseOut' event


I think this will do it:

outside of any function (i.e. a global var):
var noMouseOut = false; /// default "state" where MouseOut
actions are done normally

Then in the onMouseOver function:
noMouseOut = false;  // on entry assure this is false

Then in the onClick function:
noMouseOut = true;  // if onMouseOut occurs after this, suppress action

Then in the onMouseOut function (at start prior to existing code):
if (noMouseOut)   // test if should suppress the action
return;

This should do it!!

-----Original Message-----
From: Laphan [mailto:laphan@u...]
Sent: Tuesday, November 07, 2000 12:43 PM
To: javascript
Subject: [javascript] Stopping an 'OnMouseOut' event


Hi All

I wondered if you could give me some valuable assistance with a JavaScript
problem that I am having.  Basically, the problem is that I have three
events (onmouseover, onmouseout and onclick) tied to each image on my
navigation bar and I want to stop processing the 'onmouseout' event if the
user clicks on the image and fires the 'onclick' event.

My code (with comments) is as follows:

<SCRIPT LANGUAGE="JavaScript">

function fixlight(fcus) {         <- this function highlights the 'clicked'
image and 'dulls' the other images
clearInterval(highlighting)    <- this stops the highlightling function
below from executing
for (i = 1;i < 4;i++)             <- this is simple loop to 'dull' all
images first
 {
  document.images(i).filters.alpha.opacity = 20; <- this sets the 'dullness'
of the images
 }
fcus.filters.alpha.opacity = 100; <- this then makes the 'clicked' image
back to full colour
}


function high(which2){         <- this function is for highlighting the
images when they are 'moved over' by the mouse
theobject=which2
highlighting=setInterval("highlightit(theobject)",1)
}


function low(which2){            <- this function is for 'dulling' the
images when the mouse is 'moved out'
clearInterval(highlighting);
which2.filters.alpha.opacity=20;
}

function highlightit(cur2){       <- this creates the highlighting from the
high function
if (cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=5
else if (window.highlighting)
clearInterval(highlighting)
}

</SCRIPT>

<BODY>

<A href="home.html" target="viewer">
<IMG src="gifs/btn-home.gif" border="0" width="79" height="60"
onmouseout=low(this) onmouseover="high(this)" onClick="fixlight(this)"
style="FILTER: alpha(opacity=40)"></A><BR>

<IMG height=8 hspace=0 src="gifs/spacer.gif" width=1><BR>

<A href="features.html" target="viewer" >
<IMG src="gifs/btn-features.gif" border="0" width="106" height="60"
onmouseout="low(this)" onmouseover="high(this)" onClick="fixlight(this)"
style="FILTER: alpha(opacity=40)"></A><BR>

<IMG height=8 hspace=0 src="gifs/spacer.gif" width=1><BR>

<A href="appraisals.html" target="viewer">
<IMG src="gifs/btn-appraisals.gif" border="0" width="121" height="60"
onmouseout=low(this) onmouseover=high(this) onClick="fixlight(this)"
style="FILTER: alpha(opacity=40)"></A><BR>


The events of the above 3 buttons/images are self-explanatory.  When I use
the onClick event I gt the full highlight as I want, but I want the image to
stay highlighted until the user clicks on another image.  At the moment, as
soon as I (the user) start to move away from the image the
onmouseout=low(this) event is fired.

Can anybody help?

Best regards


Laphan

mailto:laphan@u...




  Return to Index