title: Uncaught SyntaxError: Unexpected token (
body: <p>Trying to use the following code in a page test.html:</p>
  
  <pre><code>&lt;script language = "javascript"&gt;
  function test()
  {
      if (typeof a != "undefined")
      {
          document.body.innerHTML = "";
          document.write(a);
      }
      else
      {
          document.body.innerHTML = "";
          document.write("a is undefined");
      }
      var a = "a is defined";
      document.write("&lt;br&gt;&lt;br&gt;");
      document.write("&lt;a href='javascript:void(0)' onclick='function(){ test(a); }'&gt;test&lt;/a&gt;");
  }
  window.onload = function(){ test(); }
  &lt;/script&gt;
  </code></pre>
  
  <p>Results in the error "Uncaught SyntaxError: Unexpected token (". How would I get the link to clear the page and display the corresponding variable?</p>