【问题标题】:Gecko Window doesnot contain a definition of JSContextGecko Window 不包含 JSContext 的定义
【发布时间】:2017-09-27 05:48:29
【问题描述】:

我的代码是说 Gecko Window 不包含 JSContext 的定义

string outString = "";
using (AutoJSContext js = new AutoJSContext((nsISupports)geckoWebBrowser1.Window.JSContext))
{
js.EvaluateScript(@"window.alert('alert')", out outString);
}

【问题讨论】:

  • GeckoFx 是哪个版本的?
  • 壁虎版本是45.0

标签: javascript c# gecko geckofx geckodriver


【解决方案1】:

您不需要 AutoJSContext 来评估脚本。您可以尝试以下方法:

myBrowser.Navigate("javascript:void(window.alert('alert'))")

在此处查看更多详细信息 https://bitbucket.org/geckofx/geckofx-45.0/issues/37/what-replaces-autojscontext

但是,如果您确定需要 AutoJSContext,那么这仍然有效(窗口为 GeckoWindow):

using (AutoJSContext context = new AutoJSContext(this.Browser.Window))
            {
                string result;
                context.EvaluateScript("window.find('',0,0,0,0,1,1)", out result);
            }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-19
    • 2018-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多