简体   繁体   English

Javascript单击iframe内的坐标

[英]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 我搜索了一些关于用javascript点击坐标的东西,我发现这行代码可以帮助你点击x,y坐标

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. 因此,当我放置html元素或按钮的宽度和高度时,它点击它很好,它将我重定向到我想要的页面。

But when i have an iframe html object (like a google ad) it doesnt work. 但是,当我有一个iframe html对象(像谷歌广告),它不起作用。 I cant understand why though because i think "click()" is like simulating a normal mouse click... or am I wrong with this? 我不明白为什么,因为我认为“click()”就像模拟正常的鼠标点击......或者我错了吗?

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. 我已经读过iframe有一个保护你不能进入html元素,但我想弄清楚的是如何模拟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. 如果可以以编程方式触发iframe中的点击事件,则可以代表访问您网页的用户触发某些操作。 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. 例如,您可以在iframe中打开自己的Twitter帐户 - 登录页面的访问者 - 然后让用户点击关注按钮关注您。 You can certainly think of more critical examples... 你当然可以想到更关键的例子......

Basically, you could take over all accounts the user is logged in with a cookie. 基本上,您可以接管用户使用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. 您可以在iframe中打开任何网页,并通过模拟点击或键盘事件代表登录用户执行操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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