0

I am trying to jquerify gecko web page to ExecuteJQuery but I am facing error saying: ReferenceError: $ is not defined StackTrace: @:1:1 don't know what i should do to fix that

GeckoScriptElement scriptJQuery = geckoWebBrowser.Document.CreateElement("script") as GeckoScriptElement;
scriptJQuery.Type = "text/javascript";
scriptJQuery.SetAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js");
scriptJQuery.Src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js";
geckoWebBrowser.Document.Head.AppendChild(scriptJQuery);
geckoWebBrowser.ExecuteJQuery("$('[name=\"message\"]').text('Something goes here');");
mplungjan
  • 169,008
  • 28
  • 173
  • 236
Brian dean
  • 103
  • 1
  • 1
  • 8
  • EITHER `scriptJQuery.SetAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js");` OR `scriptJQuery.Src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js";` not both. Also VERY old jQuery lib (7 years old?) – mplungjan Jan 25 '17 at 13:17
  • removed SetAttribute("src",""); function and changed jquery source to : scriptJQuery.Src = "https://code.jquery.com/jquery-latest.min.js"; still facing the same issue! – Brian dean Jan 25 '17 at 13:23
  • have a read of this: http://stackoverflow.com/questions/24036383/how-to-load-another-jquery-version-from-geckowebbrowser-control – mplungjan Jan 25 '17 at 13:30
  • still didn't work ;( – Brian dean Jan 25 '17 at 14:21
  • ExecuteJQuery is really a thing? - you have `Gecko.JQuery.JQueryExecutor JQexecutor = new Gecko.JQuery.JQueryExecutor(GeckoBrowser.Window); try { JsVal value = JQexecutor.ExecuteJQuery(@"$.getScript('https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js', function(){ alert('Script loaded and executed.'); });"); } catch (Exception ex) { string exMessahe = ex.Message; } ` – mplungjan Jan 25 '17 at 14:30
  • it gave me the same error message: "JSError : ReferenceError: $ is not defined StackTrace: @:1:1" – Brian dean Jan 25 '17 at 15:33

0 Answers0