简体   繁体   English

如何修复 TypeError:浏览器未定义?

[英]How to fix TypeError: browser is not defined?

I have an issue with onclick browser action.我有 onclick 浏览器操作的问题。 All the time it shows TypeError: browser is not defined if i do put in try catch Tried manually inseritng into firefox console, no success still not defined.它一直显示 TypeError: browser is not defined if i put in try catch 尝试手动插入 firefox 控制台,仍然没有定义成功。 Using firefox 55. How to overcome the issue?使用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);

Manifest显现

    {
"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"]

}

Output of background script goes to specific Debug page, not to output of firefox console .后台脚本的输出转到特定的 Debug 页面,而不是 firefox console 的输出。 Extensions-> Debug Extension -> Allow debugging-> Debug on extensions.扩展-> 调试扩展-> 允许调试-> 调试扩展。 New console outputs, where everything comes to display Browser variable only supported in Debug console, not in developer tools console新的控制台输出,所有内容都显示浏览器变量仅在调试控制台中支持,在开发人员工具控制台中不支持

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM