When to use event.initMouseEvent for simulating mouse clicks?
Posted
by
Protector one
on Programmers
See other posts from Programmers
or by Protector one
Published on 2013-07-25T10:46:32Z
Indexed on
2014/08/19
16:29 UTC
Read the original article
Hit count: 175
JavaScript
|websites
I wonder if there are benign use-cases for simulating mouse clicks using event.initMouseEvent. I found that it is used for creating pop-under ads in the following way:
var e = document.createEvent('MouseEvents');
e.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, true, false, false, true, 0, null);
a.dispatchEvent(e);
This code simulates a click on the opening browser window, to force the newly opened window beneath it. Evil.
I'm thinking of simply preventing all simulated clicks in my own browser via a browser extension, but I wonder if I might break useful websites and behavior in the process. Therefore I wonder what situations justify simulating mouse clicks, and if there are big sites that use it in non-evil ways.
© Programmers or respective owner