我想在火狐扩展中包含jQuery。
我添加了以下代码行来导入jQuery文件:
Components.utils.import("resource://js/jquery.js", window.content.document);Firefox在导入后立即运行该文件。带有匿名闭包的jQuery文件如下所示:
(function( window, undefined ) {
...bunch of code....
_jQuery = window.jQuery,
})(window);当扩展运行时,会出现错误"window is not defined“。授予jQuery对窗口的访问权限的方法是什么?
发布于 2011-02-19 16:42:17
将此代码写入您的*.xul文件以包含jQuery。
<script type="application/x-javascript" src="toolbar.js"></script>发布于 2010-11-10 15:30:45
没有经过测试,但在正常的网站上,jQuery会加载到window的上下文中。因此,您必须使用window.content作为作用域:
Components.utils.import("resource://js/jquery.js", window.content);window.content.document不包含属性window。
发布于 2010-11-10 03:06:07
如果与greasemonkey userjs相同,请尝试使用unsafeWindow,而不是window。
https://stackoverflow.com/questions/4137353
复制相似问题