title: javascript confirm action using document.write
body: <p>I have a javascript function that I am trying to call when the confirm is true. I am using document.write because the source document is a .js file, not html.</p>
  
  <p>Before the true condition is executing, I want a confirmation from the user that they are sure they want to reset the counter.</p>
  
  <p>I have two attempts - the first of which is returning true of false, but not calling the resetCookie() function on the true condition.</p>
  
  <p>The second attempt is, i think, syntactically incorrect, as it appears to do nothing.</p>
  
  <p>1st attempt:</p>
  
  <pre><code>document.write('&lt;a href="" onclick="return alert(confirm(\'sure?\'));{resetCookie()}{};"&gt;&lt;i&gt;Reset counter&lt;/i&gt;&lt;/a&gt;'); 
  </code></pre>
  
  <p>2nd attempt:</p>
  
  <pre><code>document.write("&lt;a href='javascript: if (confirm('Continue?')) { alert('You chose true') } else { alert('You chose false.') }; void('')'&gt;Reset counter&lt;/a&gt;");
  </code></pre>
  
  <p>thank you for assistance.</p>