首页 > 解决方案 > 在 Edge 上启用 page_action 图标但没有弹出窗口

问题描述

我无法让一个微不足道的 page_action 在 Edge 中工作。它变为活动状态,但不会像浏览器操作那样弹出弹出 html。

mainifest.json

        {
        "manifest_version" : 2,

        "name": "Page action",
        "version": "0.1",
        "description": "Hello World",

        "page_action": {
            "default_icon": "icon16.png", 
            "default_title": "PageActioner",
            "default_popup": "popup.html"
          },

        "background": {
            "scripts": ["background.js"]
         }             
         }

背景.js

        console.log("This goes nowhere would be good to get working.");

        chrome.tabs.query({currentWindow: true, active: false}, function(tabs) {
               chrome.pageAction.show(tabs[0].id);  // Colored in first tab, hacky but works
         });


        // This can work, but should not be needed and pops up in the wrong place
       // let winUrl = chrome.extension.getURL("popup.html");
        // chrome.pageAction.onClicked.addListener(function (tab) { 
        //   let wd=window.open(winUrl,  "_blank",  width=500,height=200,left=1,top=1,location=1");
        // });
                        

会不会是权限问题?有没有办法在开发时说 all_permissions?(我正在从文件中加载它。)

此外,console.log() 似乎消失了,但警报似乎有效。

任何帮助表示赞赏。

标签: google-chrome-extension

解决方案


由于毫无意义的原因,这开始神奇地起作用。我将把它作为一个简单的 page_action 示例留在这里,它可能会对某人有所帮助。


推荐阅读