<script type="text/javascript">
var r = confirm("Press a button");
if (r == true) {
    <?php header('location:index.php');?>
}</script>
//Its redirect in index.php without conformation dialog and below code execute properly no any code contain simple navigation code..
<script type="text/javascript">
    var r = confirm("Press a button");
    if (r == true) {
       x = "You pressed OK!";
    }</script>
 
     
    