简体   繁体   中英

Auto click button inside iframe

I'm trying to automate the join event, it's a groove page with a default form. I need to skip "join button" and automatically redirect people to another page.

The only way is to trigger an auto click using js.

But it's not working in my case

function myFunction() { 
    var data = document.getElementById("count_id").value;
    var  datacount = (parseInt(data) + 1);
    document.getElementById("count_id").value = datacount;  
    document.getElementById("clickbutton").value = "Clicked";
}

setInterval(function(){
    document.getElementById("clickbutton").click(); 
}, 3000);

This code works well, but the button is inside an iframe, and it is added using inspect element. Using document.getElementsByClassName I get the error document.getElementsByClassName(...).click is not a function

You can use this: document.getElementById('iFrameId').contentDocument.getElementById('clickbutton').click()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM