$(window).on("beforeunload", function () {
    debugger;
    var tid = getCookie();
    console.log("TestId =" + tid);
    if (tid != "") {
        setTimeout(function () {
            window.location = "DeleteRec.aspx";
        }, 3000);
    }
    else {
        console.log("Not Run");
    }
})
 
This is my code not redirct other page . What's problem this code. Any help me.