jQuery在Firefox扩展 [英] jQuery in Firefox extension

查看:129
本文介绍了jQuery在Firefox扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Firefox扩展中包含jQuery。



添加以下代码行来导入jQuery文件:

  Components.utils.import(resource://js/jquery.js,window.content.document); 

Firefox在导入后立即运行文件。 jQuery文件看起来像这样用匿名关闭:

pre code $(函数(窗口,未定义){
...一堆代码....
_jQuery = window.jQuery,
})(window);

扩展运行时出现错误未定义窗口。什么是让jQuery访问窗口的方法?

解决方案

将此文件写入* .xul文件以包含jQuery。 / p>

 < script type =application / x-javascriptsrc =toolbar.js>< / script> 


I would like to include jQuery in a Firefox extension.

I add the following line of code to import the jQuery file:

Components.utils.import("resource://js/jquery.js", window.content.document);

Firefox runs the file immediately after importing. The jQuery file looks like this with an anonymous closures:

 (function( window, undefined ) {
        ...bunch of code....
       _jQuery = window.jQuery,
 })(window);

When the extension runs there is an error "window is not defined". What is a way to give jQuery access to the window?

解决方案

Write this to your *.xul file to include jQuery.

<script type="application/x-javascript" src="toolbar.js"></script>

这篇关于jQuery在Firefox扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆