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 - if(confirm("your text here")){ var url = 'URL Here'; // pass your url here g_navigation.open(url, '_blank'); } ... 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 confirm() javascript function like this
🌐
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.
🌐
Stack Overflow
stackoverflow.com › questions › 27368467 › redirecting-pages-with-confirmation
Redirecting pages with confirmation
<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>
Find elsewhere
🌐
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> ......
🌐
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" />
🌐
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 26, 2014 - 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); }