如何修复TypeError:浏览器没有定义?
我遇到了onclick浏览器操作问题。 它所有的时间显示TypeError:浏览器没有定义,如果我确实放在尝试捕获 尝试手动inseritng到Firefox的控制台,没有成功仍然没有定义。 使用firefox 55. 如何解决这个问题?如何修复TypeError:浏览器没有定义?
console.log("Start 1")
function run(){console.log(1)}
browser.browserAction.onClicked.addListener(run);
var interval1Id = setInterval(function(){
\t var id = document.querySelector(".myclass").id
\t document.getElementById('m1).contentWindow.document.getElementById(id).click();
\t var newDate = new Date();
\t console.log("Function executes at : " +newDate)
},10000); \t
清单
{
"applications": {
"gecko": {
"id": "[email protected]",
"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 . 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
虽然这是中等准确的,但如果是引用,则需要声明源。此外,无法根据您的问题确定这是实际的答案。事实上,根据你的问题,它*不能是唯一需要的或你的问题。它确实涵盖了你的问题隐含的部分内容。它通常只涵盖你想要访问扩展的上下文中的控制台的问题,而不是页面上下文。 – Makyen
你到底想达到什么目的?没有名为浏览器的全局变量。 – Daniel
'浏览器'对象很可能不适用于内容脚本,并且只能在后台脚本中使用 –
如果您要检查Firefox web ext开发人员指南,则在他们的示例中他们使用此变量。 喜欢这里:https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Your_second_WebExtension 我想通过点击FF工具栏中我的Web扩展的图标来运行函数 –