Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8964885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:41:18+00:00 2026-06-15T16:41:18+00:00

I have read the many posts on this matter and tried all the ways

  • 0

I have read the many posts on this matter and tried all the ways to include jQuery.

If I load the jQuery in the xul file and store it in a variable it works.
(as in How to use jQuery in Firefox Extension)

jQuery.noConflict();
sbsh.safeWalletUtils.$ = function (selector, context) {
    return new jQuery.fn.init(selector, context || doc);
};
sbsh.safeWalletUtils.$.fn = sbsh.safeWalletUtils.$.prototype = jQuery.fn;

However, I suspect that the suggest solution here is much better:
http://forums.mozillazine.org/viewtopic.php?f=19&t=2105087

loadjQuery: function(wnd){
  var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
 .getService(Components.interfaces.mozIJSSubScriptLoader);
  loader.loadSubScript("chrome://clhelper/content/jquery/jquery-1.5.js",wnd);
  var jQuery = wnd.jQuery.noConflict(true);
  loader.loadSubScript("chrome://clhelper/content/jquery/jquery.hoverIntent.js", jQuery);
  return jQuery;
 },

in Page Load event handler:

var doc = event.originalTarget;
var wnd = doc.defaultView;
// load jQuery and save it as a property of the window
myprivatejQuery = loadjQuery(wnd)

However I keep getting wnd.jQuery undefined..(few people in the link also said that was the problem)

What should I do?
How do I use jQuery and not worry about conflict inside a Firefox extension?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:41:19+00:00Added an answer on June 15, 2026 at 4:41 pm

    After more investigation, and thanks to Omri Baumer for he relentless work..

    We now understand why we get the error.

    The right way to do it is not in the xul file as an include (as I suspected) but via calling the unwrapped js object:

    // correct function to load jQuery
    var loadjQuery = function(wnd){
      var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
       .getService(Components.interfaces.mozIJSSubScriptLoader);
       loader.loadSubScript("chrome://sbshsafewallet/content/jquery-1.8.3.js", wnd);
       var jQuery = XPCNativeWrapper.unwrap(wnd).$;
       jQuery.noConflict(true);
      return jQuery;
    };
    
    
    // field to store the jQuery for the current document window (as there can be multiple tabs)
    var jQueryForWindow = null;
    
    // event to call on window load (didn't include the code, left for reader to do)
    windowLoad = function (event)
    {
        var appcontent = document.getElementById("appcontent"); // browser  
        appcontent.addEventListener("DOMContentLoaded", pageLoadedInit, false);
    }
    
    // load jQuery on DOMContentLoaded event
    pageLoad = function (event) {
          var doc = event.originalTarget;
          var wnd = doc.defaultView;
          jQueryForWindow = loadjQuery(wnd);
    }
    
    
    //example of function using the jQuery
    function usesjQuery()
    {
       var $ = jQueryForWindow;
       //do something with jquery here
    }
    

    Hope this helps all of you that have been stuck!!

    Thanks again to Omri Baumer!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read many posts on this topic; among them and most recently .NET
I have read many posts about this now but I do not still understand
I have read many posts on this, especially here on this site, but I
OK perhaps I have read too many posts on this subject and now I
I have read many posts on here regarding this issue; The answers of 'Why
I am really struggling on this one; I have read many different posts and
I have read many answers regarding this still i am getting confused if i
Alright...I've given the site a fair search and have read over many posts about
I have read many posts regarding deserialization of nullable fields but have not run
I have read many posts about setting up unit testing in Zend Framework and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.