Running script after'')

setTimeout(() => {

let c = prompt ("What is the password?")

let password = ['Ax', 'Buax','Oyl'];

function detectpassword(){
    if (c == password) {
        alert ('Thats the correct password');
    } else {
        alert ('Sorry thats wrong');

}, 10000);

Hello , what I’m trying to do that open that new window then execute the script on it but It just opens the new window and executes the script on the previous page not the one I just opened.


I suspect you don’t own the target site You will not be able to execute an arbitrary script there. This is a security measure. If this was not the case, anyone could embed full-screen and read any data from it.

To execute an arbitrary script on anothre page you will need to create browser extension. Then you can use cross-tab communication to forward the password to your application.