Search code examples
javascriptdom-eventsmicrosoft-edgetouch-eventwindows-10-mobile

'ontouchstart' in window returns true in MS Edge browser phone emulator, but the touchstart event is not fired


When I select the Windows Phone 10 browser profile at the Microsoft Edge developer tools emulation tab, 'ontouchstart' in window returns true but the touchstart event is not fired.

Is this a bug? Does a real Windows 10 phone behave the same way? Is there a way to emulate touchstart on Edge?

Note: I know the pointerup event, but I thought that, if only pointerup is fired, 'ontouchstart' in window should be false.

Test at jsfiddle


Solution

  • Are you using a mouse?

    I don't know if Edge is supposed to simulate a touchscreen event when it's using the Windows Phone 10 browser profile, but my guess would be that it wouldn't. Laptops (nowadays) often have touch screens, and these create touchstart events on desktop Edge (and IE if I recall correctly), so Microsoft may have decided that the input method (mouse vs. touch vs. pen) shouldn't be considered part of the desktop/mobile distinction.

    Anyway, if you do have a computer with a touchscreen handy, you can use that to test touchstart/touchend, but I'm not sure how else to do it.