我正在开发一个Firefox Mobile (Fennec)扩展,我想在内容脚本中使用jQuery。做这件事最好的方法是什么?
我在Firefox Mobile4的桌面版本上进行测试
发布于 2011-12-07 17:04:25
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);https://stackoverflow.com/questions/8376416
复制相似问题