问题
I have a winform application that contains a c# webbrowser control.Webbrower control load a html page. On that html page I have a button. What I want is when click that button, it will call a winform function(function in Form1.cs for example). Is it possible? Please help me
回答1:
Use window.external object in your scripting code to access public properties and methods of the specified object. (See the sample in the link)
C#
public void Test(String message)
{
MessageBox.Show(message, "client code");
}
HTML
<button onclick="window.external.Test('called from script code')">
call client code from script code
</button>
来源:https://stackoverflow.com/questions/11331146/call-winform-function-from-html-page