JSFiddle - React, Tailwind, and code Playground

HTML

<button id="click">Click to open a new window and execute the function !</button>

JavaScript

function openWindow(path, callback /* , arg1 , arg2, ... */){
    var args = Array.prototype.slice.call(arguments, 2);
    var w = window.open(path);
    w.addEventListener('load', afterLoadWindow.bind(w, args), false);
    function afterLoadWindow(/* [arg1,arg2,...], loadEvent */){
        callback.apply(this, arguments[0]);
    }
}

document.getElementById("click").addEventListener("click",function(){

    openWindow("/",function(firstname, lastname){
        this.alert("Hello "+firstname+" "+lastname);
    }, "John", "Doe");
    
});