title: How to handle a JS event with InvokeScript in a WebView
body: <p>In order for C# to extract information from a WebView or to react to an event, we use InvokeScript. However, InvokeScript does not seem to property attach to events. What's wrong?</p>
  
  <pre><code>private void WebView_LoadCompleted(object sender, NavigationEventArgs e)
  {
      var _WebView = sender as WebView;
      _WebView.AllowedScriptNotifyUris = WebView.AnyScriptNotifyUri;
      _WebView.AllowedScriptNotifyUris.Add(e.Uri);
  
      // test1 fires immediately
      _WebView.InvokeScript("execScript", new[] { "window.external.notify('test1'); " });
  
      // test2 never fires
      _WebView.InvokeScript("execScript", new[] { "document.addEventListener = function (e) { window.external.notify('test2'); }" });
  
      // test3 never fires
      _WebView.InvokeScript("execScript", new[] { "function x(e) { window.external.notify('test3'); } document.addEventListener('onmousedown', x);" });
  
  }
  
  private void WebView_ScriptNotify(object sender, NotifyEventArgs e)
  {
      // listen for external.notify event
      System.Diagnostics.Debugger.Break();
  }
  </code></pre>