我正在开发一个Firefox Mobile(Fennec)扩展,我想在内容脚本中使用jQuery。 做什么是最好的方法?如何在Firefox Mobile(Fennec)扩展的内容脚本中使用jQuery?
我做的Firefox移动4
我正在开发一个Firefox Mobile(Fennec)扩展,我想在内容脚本中使用jQuery。 做什么是最好的方法?如何在Firefox Mobile(Fennec)扩展的内容脚本中使用jQuery?
我做的Firefox移动4
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);
您使用的是附加SDK?你为什么问这个问题?如果你已经有一个内容脚本,你可以像这个例子一样加载jquery:https://addons.mozilla.org/en-US/developers/docs/sdk/1.2/dev-guide/addon-development/content- scripts/reddit-example.html – Nickolay
我没有使用附加SDK,据我所知没有Firefox Mobile的附加SDK(Fennec)。 – benkol
@benkol在github上有一个将请求移植到移动设备的请求:https://github.com/mozilla/addon-sdk/pull/245。这是非常实验性的。请让我知道,如果你设法让它工作。 – BenoitParis