问题描述
在后台脚本的firefox扩展中,我们正在检查当前正在加载的标签,并检查该URL是否是我们所需的URL(如果它是我们所需的URL),那么我们将在浏览器的帮助下在该标签上执行一个javascript文件。使用browser.tabs.executeScript的tabs.onupdated事件,并且文件已成功执行,但内容脚本上出现的window.onload事件未执行 但是在内容脚本中执行的第一行的console语句
Background.js
browser.tabs.onUpdated.addListener(
function (tabId,changeInfo,tab) {
// here checking wether to execute the script for the currently loading tab based on the URL of tab
browser.tabs.executeScript(tab.id,{ file: "jquery.min.js" });
browser.tabs.executeScript(tab.id,{ file: "automate.js" });
},{ properties: ["status"] }
);
automate.js
console.log("automate.js executing");
window.addEventListener("load",function(){
// this console.log statement not printed
console.log("window is loaded");
})
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)