0

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 !

LeMoussel
  • 5,290
  • 12
  • 69
  • 122

1 Answers1

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>
John Hatton
  • 1,734
  • 18
  • 20
  • Hmm, OK. Check out [this SO answer](http://stackoverflow.com/a/950146/723299)... it could be just a matter of waiting for it to load. – John Hatton Jun 04 '14 at 16:58