lundi 1 février 2021

Javascript button click in another url

There are url1 and url2. I am in url1. url2 has a checkbox and a button that I want to check and click. url1 has a button that I made and when I click it then...

  1. open window in url2.
  2. check the checkbox.
  3. click the button.

However, my button will only open a window with url2 and it will not check the checkbox nor click the button. Maybe the website isn't loaded yet?

I hope it doesn't open a window in url2 and just check the checkbox and click the button if it's possible. If that's impossible then teach me how to fix this so 1),2),3) will be executed in the right order, please.

My codes are...

function reply_del1() {
var button1 = document.createElement("button");
button1.innerHTML = "DeleteComments";

var body1 = document.getElementsByTagName("body")[0];
body1.appendChild(button1);

button1.addEventListener ("click", function() {

var url2 = "http://somesite12345.com/attendance/cmt.php";//1)
window.open(url2);

$('#check_all').trigger('click');//2)

document.getElementsByName("btn_delete")[0].click();//3)
});
}



Aucun commentaire:

Enregistrer un commentaire