모든 웹 페이지의 기초에 툴바를 가져 오는 firefox 확장 기능을 개발하려고합니다.firefox 확장 기능에서 jQuery 사용하기
는 지금까지 내가 jQuery를 작동하게 관리하고 나는 mr.on = 함수()에
$("body",mr.env).css("background","black");
를 실행하여 증명했다.
이 코드는 addon과 관련된 메뉴 항목을 클릭 할 때마다 웹 페이지의 배경색을 검정색으로 만 만듭니다.
하지만, 내가 그것을 단순히 실패$('body',mr.env).append(' <img src="img/check.png" /> ');
를 실행하려고합니다. 오류 콘솔에 오류를 표시하지 않으며 이미지가 표시되지 않습니다.
왜 그럴까요?
<script src="window.js"/>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery-1.4.4.min.js"></script>
<!-- Firefox Tools menu -->
<menupopup id="menu_ToolsPopup">
<menuitem id="menu_crypt_demo" class="" image=""
label="Use DnsResolver?" insertbefore="javascriptConsole" accesskey="o"
oncommand="DnsResolver.onMenuItemCommand(event);">
</menuitem>
</menupopup>
이 자바 스크립트 파일 (window.js) :
이
는 XUL 내 오버레이입니다var DnsResolver = {
onLoad: function() {
// initialization code
this.initialized = true;
},
onMenuItemCommand: function() {
testextension.on();
window.open("chrome://dnsresolver/content/window.xul", "", "chrome");
}
};
window.addEventListener("load", function(e) { DnsResolver.onLoad(e); }, false);
if(!testextension){ var testextension={};}
(function(){
var mr=testextension;
mr.on=function(){
mr.loadLibraries(mr);
var jQuery = mr.jQuery;
var $ = function(selector,context){ return new jQuery.fn.init(selector,context||window._content.document); };
$.fn = $.prototype = jQuery.fn;
mr.env=window._content.document;
/*$("body",mr.env).css("background","black");*/
$('body',mr.env).append('<img src="img/check.png" />');
$(mr.env).ready(function(){
// hide and make visible the show
$("span.close a",mr.env).click(function() {
$("#tbar"),mr.env.slideToggle("fast");
$("#tbarshow",mr.env).fadeIn("slow");
});
// show tbar and hide the show bar
$("span.show a",mr.env).click(function() {
$("#tbar",mr.env).slideToggle("fast");
$("#tbarshow",mr.env).fadeOut();
});
});
/*$("body",mr.env).css("background","black");*/
}
// Loading the Jquery from the mozilla subscript method
mr.loadLibraries = function(context){
var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://dnsresolver/content/jquery-1.4.4.min.js",context);
var jQuery = window.jQuery.noConflict(true);
if(typeof(jQuery.fn._init) == 'undefined') { jQuery.fn._init = jQuery.fn.init; }
mr.jQuery = jQuery;
}
})();
하나의 코멘트 사용자 대역폭을 절약 할 수있는 JDK (Google)를로드하는 데 CDN을 사용하는 것이 좋을 것입니다. –
@Tom 아주 나쁜 생각, FireFox 확장은 하드 드라이브에 있으므로 하드 드라이브에서로드하는 것이 빠릅니다. –