I am trying to code an auto clicker that can open a new tab on the click of an HTML button and start clicking. When clicked, JS should open a new tab and begin clicking. However, it does not seem to work. I have figured out that the JS will not run on a new tab, but I can't figure out how to fix it. Code sample below:
function updateButton() {
window.open("https://clickthatbutton.com", '_blank');
document.getElementById("submit").click();
}
Documentation says window.open
returns object representing created window. So you can store it in variable and access its document:
function updateButton() {
const w = window.open("https://clickthatbutton.com", '_blank');
w.document.getElementById("submit").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.