[英]C# GeckoFX - Calling a JS function from the navigated Page
I am trying to call my function "initialize" in the navigated page using GeckFX(version 33), I have tried the following actions: 我试图使用GeckFX(版本33)在导航页面中调用我的函数“初始化”,我尝试了以下操作:
_wb.Navigate("javascript:void(initialize());");
and 和
using (Gecko.AutoJSContext context = new AutoJSContext(_wb.Window.JSContext))
{
var result = context.EvaluateScript("initialize();", _wb.Window.DomWindow);
}
both didn't work. 两者都不起作用。 the first one didn't even return an error, the second one returned the following error message:
第一个甚至没有返回错误,第二个返回了以下错误消息:
Error HRESULT E_FAIL has been returned from a call to a COM component.
错误HRESULT E_FAIL已从对COM组件的调用返回。
I am performing those actions in the "DocumentCompleted" event handler. 我正在“ DocumentCompleted”事件处理程序中执行这些操作。 Is there something I am missing?
我有什么想念的吗?
my guess is that it didn't finish loading the page as when I stop in debug mode I don't see the web page from within this even handler(only when i continue it appears) 我的猜测是,它没有完成页面加载,因为当我停止在调试模式下时,我没有从此偶数处理程序中看到该网页(仅当我继续显示时)
any ideas how to make it work? 任何想法如何使它工作? thanks.
谢谢。
I have found the issue, I should have used: 我发现了问题,应该使用:
Application.DoEvents();
and then call 然后打电话
_wb.Navigate("javascript:void(initialize());");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.