How to redirect to a page after alert button is pressed

For example if you submit the form and a alert is shown. After clicking on ok button, you want to redirect the page to another page. Use the below code is very easy.

<script type="text/javascript"> 
    alert("review your answer"); 
    window.location.href = "index.php";