我有一个iframe,在网站的iframe中,有一个按钮,我希望在iframe加载时自动单击。这是HTML代码。
<div class="buttonnext action-button-container">
<button type="button" id="nextBtn" class="action-button red0">
<span id="nextBtn-final">
CLICK TO PROCEED
</span>
</button>
</div>发布于 2021-09-14 15:40:57
/* You can do it in this way.
1. Get Iframe element
2. Get the content window object and do a normal dom traversal to your button.
3. Trigger the event.
*/
var iframe = document.getElementById("iframe");
var elmnt = iframe.contentWindow.document.getElementsById("nextBtn");
elmnt.click();https://stackoverflow.com/questions/69180706
复制相似问题