的WinForms - 如何从WebBrowser控件内执行C#应用程序code? [英] WinForms - How do I execute C# application code from inside WebBrowser control?

查看:100
本文介绍了的WinForms - 如何从WebBrowser控件内执行C#应用程序code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含Web浏览器控件的形式。这个浏览器控件会从磁盘加载一些HTML并显示它。我希望能在我的形式在HTML访问C#code按钮。

I have a form containing a web browser control. This browser control will load some HTML from disk and display it. I want to be able to have a button in the HTML access C# code in my form.

例如,在HTML中的按钮,可以称之为窗体上的Close()方法。

For example, a button in the HTML might call the Close() method on the form.

目标平台:C#和Windows Forms(所有版本)

Target platform: C# and Windows Forms (any version)

推荐答案

看<一个href=\"http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.objectforscripting.aspx\"相对=nofollow> WebBrowser.ObjectForScripting 财产。设法让谷歌地图使用这个跟一个Windows窗体应用程序。

Look at the WebBrowser.ObjectForScripting property. Managed to get Google Maps talking to a windows forms application using this.

这篇关于的WinForms - 如何从WebBrowser控件内执行C#应用程序code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆