什么是推荐的方法来调用从C#使用的WinForms GeckoFX控制javascript函数? [英] What is the recommended way to call a javascript function from C# using the WinForms GeckoFX control?
本文介绍了什么是推荐的方法来调用从C#使用的WinForms GeckoFX控制javascript函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这些问题说明了一切。我把一切都连接起来,并知道如何从浏览器的HTML邮件发送到C#,而不是其他方式
The questions says it all. I have everything wired up and know how to send messages from the browser html to c#, but not the other way.
我应该可以做一些事情,如:
I should be able to do something like:
browserControl.JSCall("myFunction('Dave','Smith');");
...并在网页代码:
...and in the web code:
function myFunction(firstName, lastName) {
$("#mydiv").text(firstName + ' ' + lastName);
}
谢谢 - 戴夫
推荐答案
您可以做到这一点使用导航:
You can do this using Navigate:
browserControl.Navigate("javascript:void(myFunction('Dave','Smith'))");
请注意,我发现这个代码是不实际运行,直到应用程序事件循环执行。如果这是你一个问题,你也许可以跟随导航与电话
Note, I find that the code isn't actually run until the application event loop executes. If that's a problem for you, you might be able to follow the Navigate call with
Application.DoEvents();
请确保你考虑的调用DoEvents明确的危险。
Make sure you consider the dangers of calling DoEvents explicitly.
这篇关于什么是推荐的方法来调用从C#使用的WinForms GeckoFX控制javascript函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文