0

I am writing a game for both desktop and mobile browsers which involves selecting objects by dragging it to a target.

The user is allowed to select objects by clicking only if dragging is impossible with the user's browser.

On Windows Phone, all screen touches are handled by the browser to perform scrolling or turned into emulated click events. But since there is no mouse in Windows Phone, the user cannot drag any objects at all with the Windows Phone browser.

Is there a way to detect this other than detecting the Windows Phone user agent?

Sam Hanley
  • 4,707
  • 7
  • 35
  • 63
Phil
  • 1,288
  • 1
  • 10
  • 19
  • Have you looked at this? http://stackoverflow.com/questions/3974827/detecting-touch-screen-devices-with-javascript – Ja͢ck Aug 27 '12 at 08:43
  • Jack: On Windows Phone 7.x, `!!('ontouchstart' in window)` is `false`, `!!('onmousemove' in window)` is `true`, just like desktop browsers. – Phil Aug 27 '12 at 08:46
  • Didn't think dragging would be impossible with Windows Phone =( – Ja͢ck Aug 27 '12 at 08:48

1 Answers1

0

You can feature detection:

document.implementation.hasFeature("MouseEvents", "2.0");

document.implementation.hasFeature("MouseEvent", "3.0");

Both return boolean.
* notice the difference in generations; "MouseEvents" VS. "MouseEvent"

Omri
  • 278
  • 2
  • 9