【发布时间】: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 !
【问题讨论】: