Run a function on another page

Hey guys,
is it possible to run a function on page2 , triggered by a code on page1 ?

For example:
Page1:

export function button1_keyPress() {
    // run function apple on /page2
}

Page2:

function apple() {
    console.log("someone pressed the button on page1");
}

What is your ultimate goal ?

To access database or change in UI ?

Or
What is your ultimate goal ?

I want to counter the uploadbuttons on a lightbox, while they’re uploading.

I have a site, where you can contact us, the become a part of us.
On this page you can upload up to 15 images from your company.

After you click submit, the upload starts and a lightbox opens.
Because it can take some time, while the images upload, I want to make a counter that tells you "2/10 images uploaded.

I already have a code to counter how many uploadButtons you have selected:

function UploadGesamt() {
 let Alle = 1;

 if ($w("#uploadButton2").value.length > 0) {
        Alle++
    }
 if ($w("#uploadButton3").value.length > 0) {
        Alle++
    }
 if ($w("#uploadButton4").value.length > 0) {
        Alle++
    }
 if ($w("#uploadButton5").value.length > 0) {
        Alle++
    }
 if ($w("#uploadButton6").value.length > 0) {
        Alle++
    }
 if ($w("#uploadButton7").value.length > 0) {
        Alle++
    }
 if ($w("#uploadButton8").value.length > 0) {
        Alle++
    }
 if ($w("#uploadButton9").value.length > 0) {
        Alle++
    }
 if ($w("#uploadButton10").value.length > 0) {
        Alle++
    }

 let CounterAlle = String(parseFloat(Alle));

    session.setItem("UploadAlle", CounterAlle);
}

But I’m not sure how to count the already uploaded images.

So an idea would be to run a function (on the lightbox page) to add +1 to a variable. The function has to be triggerd every time, when a image is uploaded on the form page (here I want to say: If the image is uploaded, run a function on lightbox page that adds +1 to the variable).

That would be the simpelst way.

I already know another way, but that would be more complicated.

Ok, I solved this problem and it works now.
Thanks anyway.