第一点:在窗体的类上设置com可见性
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
[System.Runtime.InteropServices.ComVisible(true)]
第二点:的构造方法中设置this.webBrowser1.ObjectForScripting = this;
第三,写C#方法
///被js调用 的方法
///首先在c#中定义被js调用的方法:
public void MyMessageBox(string message)
{
MessageBox.Show(message);
}
确定第四,在js中调用
window.external.MyMessageBox("d")