title: Invoke C# code from JavaScript in a Document in a WebBrowser
body: <p>I have a C# WinForms application that has a WebBrowser control inside of it. I would like to perform two-way communication between my C# form and the JavaScript within the embedded web browser control.</p>
  
  <p>I know I can invoke a JavaScript function with <a href="http://msdn.microsoft.com/en-us/library/be9zzz62.aspx" rel="noreferrer">InvokeScript</a>, but how can I invoke C# code from JavaScript in a <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.document.aspx" rel="noreferrer">Document</a>? I guess it wont be easy due to security, but is it possible, somehow, anyhow?
  These JavaScript functions are supposed to be user functions, pretty much like macros, that would tell the WebBrowser exactly what to do with the help of a whole C# library written by myself. And since this is for a web scraper, JavaScript is the perfect language for these macros since it is pretty much made to access elements in an HTML document. </p>