title: Redirect only after confirmation
body: <p>I want to have the user click on a link then have a javascript pop-up with a yes or no choice,but if yes redirect to different url if no, then stay on the same page.
  I tried the code below but it takes me to the same page when selecting yes or no.</p>
  
  <pre><code>function YNconfirm() { 
   if (window.confirm('Really go to another page?'))
  {
      alert("You agree") 
  window.location.href = (http:///mediclaim_portal/logout2.php');
  }
  else
  {
  window.location.href = (this.document);
  }};
  &lt;/script&gt;
  
  then 
  &lt;a href="\mediclaim_portal/logout2.php" onclick="YNconfirm()"&gt;Home&lt;/a&gt;
  </code></pre>