Can you share the code you tried? Here is an example of code that worked with me on both iPhone and Chrome 19
<head> <script> function listen(elem, evnt, func) { if (elem.addEventListener) // W3C DOM5. elem.addEventListener(evnt,func,false); else if (elem.attachEvent) { // IE DOM7. var r = elem.attachEvent("on"+evnt, func); return r; } } function attachListeners() { var touch_div = document.getElementById('touch_me'); listen(touch_div,'touchmove', function(event) { touch_div.innerHTML="being touched " + event.targetTouches.length; touch_div.style.background =green; }, false); listen(touch_div,'touchstart', function(event) { event.preventDefault(); touch_div.innerHTML="touchstart"; touch_div.style.background ='green'; }, false); listen(touch_div,'touchend', function(event) { touch_div.innerHTML="thanks!"; touch_div.style.background ='#CCFF66'; }, false); listen(touch_div,'click', function(event) { touch_div.innerHTML="hey - touch, not click!"; touch_div.style.background ='red'; }, false); listen(touch_div,'onmouseup', function(event) { touch_div.innerHTML="hey - that was a click!"; touch_div.style.background =''; }, false); } function run_onload() { attachListeners(); } </script> </head> <body onload="run_onload()"> <div id="touch_me">Touch me!</div> </body>
Yasei no umi
source share