title: How to detect Javascript execution in WebBrowser control
body: <p>I have a <code>WebBrowser</code> control in my C# application. The web browser is under the user's control, that is, he can load any web page his computer can access on the web (of course limited by proxy, hosts file and so on).</p>
  
  <p>I need to know and to be notified when there is a Javascript call inside the page loaded in the web browser component.</p>
  
  <p>First example: given a link like this</p>
  
  <pre><code>&lt;a href="javascript:void(0)" onclick="jsFunct();"&gt;test&lt;/a&gt;
  </code></pre>
  
  <p>When the user clicks the link I need to know that the function "jsFunct" has been called.</p>
  
  <p>Second example: given a call like</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      window.setTimeout("jsFunct()", 1000);
  &lt;/script&gt;
  </code></pre>
  
  <p>I need to know that, 1 second after the execution of the script, the function jsFunct has been called.</p>
  
  <p>The best thing would be to have an event fired when the function is called. It would also be great if the event could get the Javascript code executed, or at least the function name in the arguments.</p>
  
  <p>EDIT:</p>
  
  <p>Even if the question is related to the webbrowser component, anything that allows the user to detect javascript activation (even via js) would be fine, being able to inject a js that handles the javascript event and passes it to the wb control triggering some event that it can handle.</p>