我想在瀏覽器操作事件(點擊工具欄圖標)上打開Firefox網絡擴展中的一些HTML文件。我是這樣做的鍍鉻的方法是:打開Firefox網頁擴展中的HTML頁面
var appId = chrome.app.getDetails().id;
var tabUrl = "chrome-extension://" + id + "/src/index.html";
chrome.windows.getCurrent(function (currentWindow) {
chrome.tabs.create({
url: tabUrl
});
});
我所試圖做的杉木Firefox是:
//firefox doesnt support chrome.app, so I have hard coded the app id in manifest under applications.gecko.id
var id = chrome.runtime.getManifest().applications.gecko.id;
var tabUrl = "moz-extension://" + id + "/src/index.html";
//I have tried chrome-extension:// also above
browser.tabs.create({
url: tabUrl,
active:true
});
它只是打開一個新標籤的URL,但頁面沒有加載。任何關於我在做什麼的錯誤
請參閱[chrome.runtime.getURL](https://developer.chrome.com/extensions/runtime#method-getURL)。你也不需要tabs.create中的完整URL。請參閱文檔。 – wOxxOm
[顯示擴展名中包含的HTML文件]的可能重複(https://stackoverflow.com/questions/40837213/show-html-file-contained-within-the-extension) – Makyen