3

Firefox Mobile(Fennec)拡張機能を開発していて、コンテンツスクリプトでjQueryを使用したいと思います。それを行うための最良の方法は何ですか?

デスクトップ版のFirefoxMobile4でテストを行っています

4

1 に答える 1

2

overlay.js

window.addEventListener("load", function (aEvent){
    document.getElementById("browsers").addEventListener("DOMContentLoaded", function onWindowLoad(aEvent){
        window.messageManager.loadFrameScript("chrome://myExtension/content/jquery.js", true);
        window.messageManager.loadFrameScript("chrome://myExtension/content/content.js", true);
}, false);

jquery.js

addEventListener('DOMContentLoaded', function(event) {
    with(content){
        /* jQuery core code goes here */
    }
}, true);

content.js

addEventListener('DOMContentLoaded', function(aEvent) { // on page load
    with(content) {
         if (aEvent.originalTarget.location.href != null) {
             if (aEvent.originalTarget.location.href == document.location.href && document.location.href != 'about:home') {
                //alert(jQuery(document).attr('title') + '\n' + jQuery(location).attr('href'));
             }
         }
    }
}, true);
于 2011-12-07T09:04:24.740 に答える