I've very new to HTML/JavaScript but am learning…
I want to make a button on an iPhone that runs a JavaScript command when it is pressed and another when it is released. I tried to do this using onmousedown
and onmouseup
properties, but this does not work the same on iPhone.
<input type="image" onmousedown="command_press()" onmouseup="command_release()" src="images/UP-Dark.png" alt="" title="" />
Could someone please tell me how to do the same thing on the iPhone?
element.onmousedown = element.onkeydown = element.ontouchstart = function() { /* event handler... */ }
. Replacing the mouse and touch event with theonpointerdown
instead, as recommended in Zectbumo's answer, fixes this problem. – Methedrine