try this:

function deletePost() {
    var ask = window.confirm("Are you sure you want to delete this post?");
    if (ask) {
        window.alert("This post was successfully deleted.");

        window.location.href = "window-location.html";

    }
}
Answer from kingkode on Stack Overflow
🌐
ServiceNow Community
servicenow.com › community › developer-forum › how-to-redirect-to-a-particular-url-after-click-ok-in-alert › m-p › 1812080
How to redirect to a particular URL after click ok in alert message.
September 7, 2020 - you should use confirm box for this. An alert does not return a value, in fact returns undefined so the easiest way is conditioning the alert like this · if(!alert("Your text here"){ var url = 'URL Here'; // pass your url here g_navigation.open(url, '_blank'); } Or another better way is using ...
🌐
ASPSnippets
aspsnippets.com › Articles › 422 › ASPNet-Show-JavaScript-Alert-Message-Box-and-Redirect-to-another-page-or-website
ASPNet Show JavaScript Alert Message Box and Redirect to another page or website
May 3, 2019 - explained with an example and attached sample code, how to show or display a JavaScript Alert Message Box and then redirect user to another page or website after he clicks OK Button in ASP.Net Website using C# and VB.Net.
Find elsewhere
🌐
Stack Overflow
stackoverflow.com › questions › 27368467 › redirecting-pages-with-confirmation
Redirecting pages with confirmation
March 11, 2022 - <button onclick="return confirm_alert('../index.html');" class="knap3" >Nej</button> <script> function confirm_alert(next) { var msg="confirmation for redirecting?"; if(confirm(msg)) { location.href=next; } } </script>
🌐
Techfunda
techfunda.com › howto › 436 › redirecting-to-other-page
Redirecting to other page in JavaScript - Tech Funda
If we want to redirect the user from current page to another page using JavaScript, we can follow this approach. <script> function TestFunction() { alert(location.href); location.href = "http://www.itfunda.com"; } </script> <input type="button" id="btnTest" onclick="TestFunction()" value="Click me" />
🌐
Stack Overflow
stackoverflow.com › questions › 61810865 › how-to-redirect-to-another-page-in-react-confirmalert
reactjs - How to redirect to another page in react confirmAlert? - Stack Overflow
import React from 'react' import ... } render() { let isRedirect = this.state.isRedirect; if(isRedirect == true){ return <Redirect to='/target' /> } return ( <div> ......
🌐
Experts Exchange
experts-exchange.com › questions › 28505331 › Page-Redirect-After-Clicking-OK-on-Message-Box.html
Solved: Page Redirect After Clicking OK on Message Box | Experts Exchange
August 24, 2001 - if (result == 0) { string message = "You will now be redirected to Google Home Page."; string url = "http://www.google.com"; string script = "window.onload = function(){ alert('"; script += message; script += "');"; script += "window.location = '"; script += url; script += "'; }"; ClientScript.RegisterStartupScript(this.GetType(), "Redirect", script, true); }
🌐
Medium
edaisyma.medium.com › html-confirm-box-and-redirect-eb991451e670
HTML/JS Popup Boxes and Redirect. Create 2 html pages and name it page1… | by E Ma | Medium
July 15, 2004 - ... Alert Box: Make sure information come though to the user. Confirm Box: Used to verify or accept something, when confirm box pops up, the user have to click “Ok” or “Cancel” (True or False) to proceed.