Javascript click on coordinates inside iframe

I searched for some things about clicking on coordinates using javascript and I found that this line of code helps you click on x, y coordinates

document.elementFromPoint(x, y).click(); 

Therefore, when I set the width and height of the html element or button, it clicks it well and redirects me to the page I need.

But when I have an iframe html object (like a google ad) it doesn't work. I can’t understand why, although due to the fact that I think that β€œclick ()” is like simulating a normal mouse click ... or am I mistaken about that?

I read that the iframe has protection that you cannot go into html elements, but all I'm trying to figure out is how to simulate a normal click on an iframe.

Thanks so much for your time.

+5
source share
1 answer

This is obviously prohibited due to security issues.

If it was possible to program the start of the click event in the iframe, you can initiate certain actions on behalf of the user who visited your page. For example, you can open your own Twitter account in an iframe - a visitor to your page is logged in - and let the user follow you by clicking the follow button. You can certainly think of more important examples ...

Basically, you can take on all the accounts that a user logged in with using a cookie. You can open any web page in an iframe and act on behalf of a registered user by simulating click or keyboard events.

0
source

Source: https://habr.com/ru/post/1237499/


All Articles