title: Uncaught ReferenceError: functionXXX is not defined at HTMLInputElement.onclick
body: <p>In my selenium automation test, I am using remote webdriver and trying to launch a html file as below. The HTML page opens correctly, but at the last part of the code, I am trying to click on a submit button which calls a javascript function (ActionDeterminator()). When that button is clicked to call the js function (ActionDeterminator()), then I see an error in console which I have mentioned at the bottom part.</p>
  
  <p>Below is the html:</p>
  
  <pre><code>String butNowButton = "&lt;!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN&gt;" +
          "&lt;HTML&gt;&lt;HEAD&gt;" +
          "&lt;META http-equiv='Content-Type' content='text/html'; charset='UTF-8'&gt;" +
          "&lt;META content='MSHTML 6.00.2900.3157' name='GENERATOR'&gt;&lt;/HEAD&gt;" +
          "&lt;BODY&gt;" +
          "&lt;H1&gt;Hello It's a testing page&lt;/H1&gt;" +
          "&lt;HR&gt;" +
  
          "&lt;P&gt;Enter the following fields and press the button to initiate Transaction" +
          "transaction&lt;/P&gt;" +
          "&lt;FORM name=SSO action='' method='post'&gt;" +
          "&lt;TABLE border='1'&gt;" +
          "  &lt;TBODY&gt;" +
          "  &lt;TR&gt;" +
          "    &lt;TD&gt;Name(*): &lt;/TD&gt;" +
          "    &lt;TD&gt;&lt;INPUT title='Name' value='Adam' name='Name'&gt;" +
          "  &lt;/TD&gt;&lt;/TR&gt;" +
          "  &lt;TR&gt;" +
  
         "    &lt;TH colSpan='2'&gt;&lt;INPUT id='btnSubmit' onclick='return ActionDeterminator();' type='submit' value='Go to Content catalog' name='btnSubmit'&gt;" +
          "    &lt;/TH&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;" +
          "    &lt;INPUT type=hidden value='https://someUrl/' name='HOOK_URL'&gt;" +
          "&lt;/FORM&gt;" +
          "&lt;SCRIPT type='text/javascript' name='JavaScript'&gt;" +
          "function ActionDeterminator()" +
          "{" +
          "document.SSO.action=document.SSO.URL.value+'/Buyer/Main/ad/somePath/DirectAction';" +
          "alert('URL is ==&gt;'+document.SSO.action);" +
          "document.SSO.submit();" +
  
          "}" +
  
          "&lt;/SCRIPT&gt;" +
  
          "&lt;HR&gt;" +
          "&lt;/BODY&gt;&lt;/HTML&gt;";
    //Below is the quick code to use above html and launch a page. This also //works fine, ( in the sense, html page is opened).
  
    String htmlDiv = "var div=document.createElement('div');div.innerHTML=\"" + butNowButton + "\";arguments[0].appendChild(div);";
  
  System.err.println("***" + htmlDiv);
  //'dr' is basically remote webdriver.
  WebElement element = dr.findElementsByTagName("BODY").get(0);
  
  dr.executeScript(htmlDiv, element);
  
  //below code tries to invoke function ActionDeterminator().
  dr.executeScript("document.getElementById('btnSubmit').click();","");
  </code></pre>
  
  <p>And in the console I see below error:</p>
  
  <pre><code>data:,:1 Uncaught ReferenceError: ActionDeterminator is not defined
      at HTMLInputElement.onclick (data:,:1)
      at &lt;anonymous&gt;:248:70
      at callFunction (&lt;anonymous&gt;:237:33)
      at &lt;anonymous&gt;:247:23
      at &lt;anonymous&gt;:248:3
  onclick @ data:,:1
  (anonymous) @ VM50:248
  callFunction @ VM50:237
  (anonymous) @ VM50:247
  (anonymous) @ VM50:248
  data:,:1 Not allowed to navigate top frame to data URL: data:,
  </code></pre>