问题描述
我有一个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。
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之间进行通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!