【问题标题】:How to load another JQuery version from GeckoWebBrowser control如何从 GeckoWebBrowser 控件加载另一个 JQuery 版本
【发布时间】:2014-06-04 11:37:59
【问题描述】:

我在 C# 中使用 Gecko 浏览器。以下代码显示 jQuery 已加载。

GeckoWebBrowser GWB = new GeckoWebBrowser .....
bool JSExec;
string JSresult = "";
string JStext = @"alert(jQuery.fn.jquery);";

using (AutoJSContext JScontext = new AutoJSContext(GWB.Window.JSContext)) 
{
   JSExec = JScontext.EvaluateScript(JStext, (nsISupports)GWB.Window.DomWindow, out JSresult);
}

警报框显示 1.4.4

是否可以加载更新版本的 jQuery?例如 2.0.2 => https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js

编辑以重播@John

是的,我正在使用 GeckoFx。要包含一个库,在

GeckoBrowser_DocumentCompleted()

我这样做:

bool JSExec;
string JSresult = "";

GeckoScriptElement scriptJQuery = GWB.Document.CreateElement("script") as GeckoScriptElement;
scriptJQuery.Type = "text/javascript";
scriptJQuery.Src = "https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js";
GWB.Document.Head.AppendChild(scriptJQuery);

string JStext = @"alert(jQuery.fn.jquery);";
using (AutoJSContext JScontext = new AutoJSContext(GWB.Window.JSContext)) 
{
       JSExec = JScontext.EvaluateScript(JStext, (nsISupports)GWB.Window.DomWindow, out JSresult);
}

Hélas !警报显示 1.4.4 !

【问题讨论】:

    标签: c# .net gecko geckofx


    【解决方案1】:

    假设您使用的是https://bitbucket.org/geckofx,它没有 jquery 版本或任何其他库。它只是一个浏览器控件。

    所以要包含一个库,你可以在你正在加载的 html 页面上指定它,就像你使用任何其他浏览器一样:

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
    

    【讨论】:

    • 嗯,好的。查看this SO answer...可能只是等待它加载的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多