title: Syntax error: Illegal return statement in JavaScript
body: <p>I am getting a really weird JavaScript error when I run this code:</p>
  
  <pre><code>&lt;script type = 'text/javascript'&gt;
  var ask = confirm('".$message."');
  if (ask == false)
  {
      return false;     
  }
  
  else
  {
      return true;
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>In the JavaScript console it says:</p>
  
  <p><code>Syntax Error: Illegal return statement</code> </p>
  
  <p>It occurs at <code>return true;</code> and <code>return false;</code></p>
  
  <p>(I am echoing this javascript from a php function; the <code>$message</code> variable is one of the php parameters)</p>
  
  <p>What is wrong with my code?</p>