Window.click event does not fire on IOS safari - JavaScript only Window.click event does not fire on IOS safari - JavaScript only angularjs angularjs

Window.click event does not fire on IOS safari - JavaScript only


When using touch based devices, the events issued to the browsers are different.It also gives the developer accurate use cases, to design and develop around.

I would assume that since there is no mouse then there will be no click event.

Taken from MDN:In order to provide quality support for touch-based user interfaces, touch events offer the ability to interpret finger (or stylus) activity on touch screens or trackpads.

Try using:document.addEventListener('touchstart', () => console.log('touch called'));

You can always opt to using function () {} instead of () => {}

See full details: https://developer.mozilla.org/en/docs/Web/API/Touch_events


I've forgotten more about Angular than I remember but I ran into this same problem when click was mapped to 'window.' Switch the listener from 'window' to 'body' fixed the issue in Safari.

Good listener

document.querySelector('body').addEventListener('click', e => {  console.log('clicked ', e)// oh yeah, I'm good!})

Bad listener

window.addEventListener('click', e => {  console.log('clicked ', e)// oh yeah, I'm good!})