How to load another JQuery version from GeckoWebBrowser control

做~自己de王妃 提交于 2019-12-12 02:47:14

问题


I use Gecko Browser in C#. The following code shows that jQuery is loaded.

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);
}

Alert box display 1.4.4

Is it possible to load a newer version of jQuery? Eg 2.0.2 => https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js

Edit to replay @John

Yes I'm using GeckoFx. To to include a library, in

GeckoBrowser_DocumentCompleted()

I do this :

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 ! Alert display 1.4.4 !


回答1:


Assuming you're using https://bitbucket.org/geckofx, it doesn't have a version of jquery, or any other library. It's just a browser control.

So to include a library, you specify it on the html page you're loading, just like you would if you were using any other browser:

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


来源:https://stackoverflow.com/questions/24036383/how-to-load-another-jquery-version-from-geckowebbrowser-control

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!