[英]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.