javascript cofirm not working in php file : <pre><code>&lt;script type="text/javascript"&gt;
var r = confirm("Press a button");
if (r == true) {
    &lt;?php header('location:index.php');?&gt;
}&lt;/script&gt;
</code></pre>

<p>//Its redirect in index.php without conformation dialog and below code execute properly no any code contain simple navigation code..</p>

<pre><code>&lt;script type="text/javascript"&gt;
    var r = confirm("Press a button");
    if (r == true) {
       x = "You pressed OK!";
    }&lt;/script&gt;
</code></pre>
