My script will click the image on the site. The image is anchored hrefand onclick href, but onclick href has a confirmation window that appears after clicking.
HTML onclick code:
onClick="this.href='link2';if (!confirm('Are you sure?')) { return false; }
How do I get a script to click OK in this confirmation window as soon as it appears?
I use this function to click the link with the image:
function click(elm) {
var evt = document.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, window, 0, 1, 1, 1, 1, false, false, false, false, 0, null);
elm.dispatchEvent(evt);
}
click(picture element)
source
share