简体   繁体   中英

Javascript click on coordinates inside iframe

I have searched some things about click on coordinates with javascript and i have found that this line of code helps you click on x,y coordinates

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

So when i put the width and height of an html element or a button it clicks it good and it redirects me to the page that i want.

But when i have an iframe html object (like a google ad) it doesnt work. I cant understand why though because i think "click()" is like simulating a normal mouse click... or am I wrong with this?

I have read that iframe has a protection that you cant go inside the html elements but all i'm trying to figure out is how to simulate a normal click on the iframe.

Thanks a lot for your time.

This is obviously prohibited due to security issues.

If it was possible to programmatically trigger a click event within an iframe, you could trigger certain actions on behalf of the user visiting your page. You could for example open your own twitter account in an iframe -- the visitor of your page logged in -- and let the user follow you with a click on the follow button. You can certainly think of more critical examples...

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM