Stopping an onMouseDown process when the mouse is up

S

stef

Hello:

I would like a process to continue as long as the mouse is held down on
a button and to stop as soon as it is released. Something ideally like
this:
"while (ButtonIsDown) {i+ = 1}"

I tried the following in the button tag:

onMouseDown = "isDown = true; while(isDown) {i+=1}"
onMouseUp = "isDown = false"

but the mouseup event does not interrupt the onMouseDown process, so the
loop will continue endlessly.

The same kind of thing happens in the <body> events; one will not
interrupt the other.

I would appreciate any suggestions.

(e-mail address removed)
 
S

stef

RobG said:
Your followup-to field appears to be incorreclty set.


This thread covers it (seach for "onmousedown is not what I expect"):

<URL:
http://groups.google.com.au/group/comp.lang.javascript/browse_frm/thread/1a5c0
02d226bccaf/ae0937955a293fd3?lnk=gst&q=onmousedown+is+not+what+I+expect+in+Jav
aScript&rnum=1#ae0937955a293fd3


Hello:

Thanks for the information - using the timeout as suggested in the
thread you mention completely solves my problem!

Stef
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top