[英]How to fix TypeError: browser is not defined?
我有 onclick 浏览器操作的问题。 它一直显示 TypeError: browser is not defined if i put in try catch 尝试手动插入 firefox 控制台,仍然没有定义成功。 使用firefox 55.如何克服这个问题?
console.log("Start 1") function run(){console.log(1)} browser.browserAction.onClicked.addListener(run); var interval1Id = setInterval(function(){ var id = document.querySelector(".myclass").id document.getElementById('m1).contentWindow.document.getElementById(id).click(); var newDate = new Date(); console.log("Function executes at : " +newDate ) },10000);
显现
{
"applications": {
"gecko": {
"id": "at@ex.com",
"strict_min_version": "52.0"
}
},
"browser_action": {
"default_icon": {
"18": "icons/btn18.png",
"38": "icons/btn18.png"
},
"default_title": "Whereami1?"
},
"manifest_version": 2,
"name": "FF 1a",
"version": "1a",
"description": "Refresh",
"background": {
"scripts": ["b.js"]
},
"content_scripts": [
{
"matches" : ["https://*/*"],
"js": ["scr.js"]
}
],
"permissions": ["webNavigation","tabs","notifications","activeTab"],
"web_accessible_resources": ["icons/btn18.png"]
}
后台脚本的输出转到特定的 Debug 页面,而不是 firefox console 的输出。 扩展-> 调试扩展-> 允许调试-> 调试扩展。 新的控制台输出,所有内容都显示浏览器变量仅在调试控制台中支持,在开发人员工具控制台中不支持
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.