Invoke C# code from JavaScript in a Document in a WebBrowser

后端 未结 3 1278
花落未央
花落未央 2020-11-27 04:06

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 e

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-27 04:15

    You're probably looking for http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.objectforscripting.aspx

    WebBrowser.ObjectForScripting lets you expose an instance of a [ComVisible] .net class to javascript code running inside the hosted web browser. It is exposed in javascript as window.external

    Excellent article from Microsoft: How to: Implement Two-Way Communication Between DHTML Code and Client Application Code

提交回复
热议问题