如何在WebBrowser实例中的WPF和JavaScript之间进行通信? [英] How to communicate between WPF and JavaScript in a WebBrowser instance?

查看:130
本文介绍了如何在WebBrowser实例中的WPF和JavaScript之间进行通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#/ WPF应用程序,该应用程序带有带有一些JavaScript的嵌入式浏览器(WebBrowser)。他们如何在双向交流?使用URL可行吗?

I have a C#/WPF application with an embedded browser (WebBrowser) with some JavaScript. How can they communicate with each other in both directions? Is it practicable to use the URL?

JS-> WPF:监听更改。
WPF-> JS:将URL更改为 javascript:alert('hello');

JS->WPF: Listen for changes. WPF->JS: Change the URL to javascript:alert('hello');

有没有更好的方法?

推荐答案

重要的是要知道有两个WebBrowser。一种用于Windows窗体,另一种用于WPF。下面的链接使用WPF。
http://www.dotnetfunda.com /articles/article840-working-with-webbrowser-in-wpf.aspx

It's important to know that there are two WebBrowser. One for Windows Forms and one for WPF. The link below uses the WPF one. http://www.dotnetfunda.com/articles/article840-working-with-webbrowser-in-wpf.aspx

这篇关于如何在WebBrowser实例中的WPF和JavaScript之间进行通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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