我正在加载iframe
,用户将用户登录到iframe
内的网站。登录后,会弹出一个OK按钮,用户必须单击该按钮才能继续。此按钮具有以下HTML:
<input type="button" class="close" value="OK">
要加载iframe
,我使用以下内容:
<form id="login" target="frame" method="post"
action="http://xxxx.com/app/1607141016/auth/login?&password=xxx&username=xxxxx">
</form>
<iframe id="frame" name="frame" width="100%" height="600"></iframe>
<script type="text/javascript">
// submit the form into iframe for login into remote site
document.getElementById('login').submit();
// once you're logged in, change the source url (if needed)
var iframe = document.getElementById('frame');
iframe.onload = function() {
if (iframe.src != "http://xxxx.com") {
iframe.src = "http://xxxx.com";
}
}
document.getElementById("frame").contentWindow.document.getElementById("button").addEventListener("click", functionToRun, false);
</script>
当iframe
的内容加载后,有没有办法让JavaScript点击按钮?