Trigger Click Inside an iframe

我只是一个虾纸丫 提交于 2019-12-14 03:25:21

问题


I have an iFrame and there is a anchor tag inside it with target="_blank". (<a href='#' target='_blank'>Link</a>)

What I want is when the page loads, the <a> tag is clicked automatically. I have tried several ways to achieve this with no luck yet.

One more thing, I can only change the code inside of the iFrame. The code of the iFrame is not in my hand.


回答1:


Because of Same Origin Policy [https://en.wikipedia.org/wiki/Same-origin_policy] browsers won't allow you do this UNLESS the iFrame and the parent page are on the same domain. You may have to try an alternative solution that doesn't involve an iFrame. A good reference to this issue is: https://stackoverflow.com/a/3076648/3188771



来源:https://stackoverflow.com/questions/33008226/trigger-click-inside-an-iframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!