简体   繁体   中英

How do I send javascript event from webbrowser wpf control to c# code of wpf

Please help to solve this problem. This is my code:

private void MyWebBrowser_LoadCompleted(object sender,     NavigationEventArgs e)
{                       
    mshtml.HTMLButtonElementEvents_Event iEvent;
    iEvent = (mshtml.HTMLButtonElementEvents_Event)e;
    iEvent.onclick += new HTMLButtonElementEvents_onclickEventHandler(ClickEventHandler);
}      

private bool ClickEventHandler()
{
    MessageBox.Show("WPF Event Handler");
    return true;
}

This is the code of the browser in WPF control. It works properly, but I can't use events in browser to invoke c# code.

iEvent.onclick += (delegate
{
    MessageBox.Show("WPF Event Handler");
    return true;
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM