Firefox extension with jquery 1.3+

前端 未结 2 479
孤独总比滥情好
孤独总比滥情好 2021-02-06 11:29

I use jquery-1.2.6 within my Firefox extensions and it works great. Some days ago i wanted to update to the current version of jquery (1.31) but this does not seem to work anymo

相关标签:
2条回答
  • 2021-02-06 12:07

    i found a solution for my problem!

    I will present it here so that others can use this as a reference. After a lot of searching and tearing my hair i found this bug report on the jquery bug tracker. You can download jquery 1.3.1 Revision: 6161 there which fixes the problem (the official 1.3.1 release is Revision: 6158).

    Another great trick a found out is including library's like jquery "on the fly" in firefox extensions. Just include the following within some javascript file within your extension:

    var jsLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);
    jsLoader.loadSubScript("chrome://{appname}/content/jquery-1.3.1_6161.js");
    jQuery.noConflict();
    
    //use jquery
    var doc = window.content.document;
    alert(jQuery("body", doc).html());
    

    Update: Today version 1.3.2 was released and the problem seems to be solved!

    0 讨论(0)
  • 2021-02-06 12:18

    After window.content.document I don't see the semicolon, I think it's necessary.

    0 讨论(0)
提交回复
热议问题