zjm1126 zjm1126 - 6 months ago 26
Javascript Question

How to get the originalEvent without jQuery on iPhone

For some reason, I can't use jQuery.

This is my code :

document.addEventListener("touchstart", function(e) {
e.preventDefault();

var orig = e.originalEvent;

var x = orig.changedTouches[0].pageX;
var y = orig.changedTouches[0].pageY;

//id("#draggable").css({top: y, left: x});
id("draggable").style.left = x;
id("draggable").style.top = y;


});

Using jQuery, you can get the
originalEvent
, but if you don't use it, how to get it?

Thanks

Mic Mic
Answer
var x = e.pageX;

If you have Safari on your desktop, open it in iPhone mode
Develop-> User Agent-> Mobile Safari...
And put a breakpoint inside your function, the you can inspect the e object and all its properties.