I am trying to trigger a click with JavaScript. I get it to work in all browsers but Safari.
I am using this code:
var t = document.getElementById('someidhere');
if (document.dispatchEvent) {
var o = document.createEvent('MouseEvents');
o.initMouseEvent('click', true, true, window, 1, 1, 1, 1, 1, false, false, false, false, 0, t);
t.dispatchEvent(o)
} else if (document.fireEvent) {
t.fireEvent('onclick');
} else if (t.click()) {
t.click()
}
This code is taken from an other StackOverflow question, but it seems to be outdated?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire