Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Repeating a function whilst mouse button is pressed?

Status
Not open for further replies.

starblood

Technical User
Joined
Feb 28, 2001
Messages
63
Location
GB
I have function that will execute a 3% zoom on a picture (java applet) when the OnClick is pressed.

Is there a way to get the function to repeat continuously if the mouse button remains pressed?

<SCRIPT LANGUAGE="JavaScript">
function ZoomInApplet()
{
document.ptviewer.ZoomIn()
}
</script>

<a href="#" OnClick="javascript:ZoomInApplet()">Zoom In</a>
 
Create a global boolean variable, set it to false on page load and mouse up, and true on mouse down.

Then execute a timer to fire every n milliseconds (using setInterval) and fire your zoom function if the flag is true.

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
OK BillyRayPreachersSon, thanks for that - I'll give it a go!

Cheers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top