Jump to content

Image disappears if clicked to fast - using mousedown and mouseup.


maja88g
 Share

Recommended Posts

Hi all, I am creating a calculator using images I have created, and am using the onmousedown and onmouseup eventsin html, to simulate 'clicking a button'. This works fine if I press the image at a moderate pace, but if i press the imagemore then once quite fast or if I double click then the image completely disappears. I have tried a number of things to fix this issue incl: timeout, sleep //written function that loops through time, calling a blankon double click, calling the mouse up from the mouse down function instead... but none of this seems to prevent the imagefrom disappearing if it has been double clicked of clicked at a fast pace. The image size is 1.37kb. Any ideas on what I am doing wrong or how I can fix this issue? Here is my html code:

 <td><image src="../images/keyboardnumbut7.gif" id="button15" onmousedown="mouseDown(this.id, this.src)" onmouseup="mouseUp(this.id,   this.src)" onClick="numkeypressed('7')"></td>

This is my javascript code:

 function mouseDown(id, src){var mySplitResultSrc;var mySplitResultImg; mySplitResultSrc = src.split("/");var msrs8 = mySplitResultSrc[8]; mySplitResultImg = msrs8.split(".");var imgname = mySplitResultImg[0];var imgext = mySplitResultImg[1]; document.getElementById(id).src = "../images/"+imgname+"me."+imgext;} function mouseUp(id, src){var mySplitResultSrc;var mySplitResultImg; mySplitResultSrc = src.split("/");var msrs8 = mySplitResultSrc[8]; mySplitResultImg = msrs8.split(".");var fullimgname = mySplitResultImg[0];var imgext = mySplitResultImg[1];var endpos = fullimgname.length - 2;var imgname = fullimgname.substring(0,endpos); document.getElementById(id).src = "../images/"+imgname+"."+imgext;}

post-64425-0-11683000-1354539643_thumb.jpg

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...