问题
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