如果我想在ifarme中自动点击按钮元素,我该如何操作呢?
null
function autoclick() {
document.getElementById('u_0_4').contentWindow.document.getElementById("u_0_5").click()
}
<div onload="autoclick()" >
<iframe src="https://www.facebook.com/plugins/like.php?href=https%3A%2F%2Fweb.facebook.com%2FMaherZain&width=450&layout=standard&action=like&size=small&show_faces=true&share=true&height=80&appId=788255487990117" width="450" height="80" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true" id="u_0_4" ></iframe>
</div>
null
=====>>; 如果有其他方法,请告诉我
你不能这样做,因为否则人们只会嵌入一个1x1的iframe,让每个访问者“喜欢”作者想要的任何东西。 允许不同源访问指向不同源的iframes的contentwindow
是一个安全问题。
想象一下如果你能做到这一点。 人们可以开始将gmail或你的银行网站嵌入到1x1的iframe中,然后触发几次点击和键盘事件来重置你的密码。