thatOneGuy thatOneGuy - 1 year ago 103
Javascript Question

Simulate click event on mobile device

I have a click event on window load like so :

function myFunction(){
document.getElementById('myEl').click(); // works on desktop, not on mobile

window.onload = myFunction;

As mentioned, this works on desktop but not on mobile devices. I gathered it was down to mobile handling click events differently. Is that correct ?

I need my element to be 'clicked' on load on all devices, desktop and touch pads (mobiles etc).

Answer Source
function myFunction() {
window.onload = myFunction;

For touch event, visit below link.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download