小编use*_*991的帖子

有没有办法在Google Chrome中的通知中插入操作按钮

我需要在chrome中添加一个通知,其中包含2个按钮'allow'和'deny'.当用户点击'allow'按钮时,它必须导航到一个网站,当用户点击'deny'时,通知框应该没有不再出现了.那就必须关闭.我怎么能这样做?请帮助我这是我的背景.js

        function getGmailUrl() {
      return "http://calpinemate.com/";
      }
        function isGmailUrl(url) {

      return url.indexOf(getGmailUrl()) == 0;
    }
      chrome.browserAction.onClicked.addListener(function(tab) {

 chrome.tabs.query({
    url: "http://calpinemate.com/*",
    currentWindow: true
    }, function(tabs) {
    if (tabs.length > 0) {
        var tab = tabs[0];
        console.log("Found (at least one) Gmail tab: " + tab.url);
        console.log("Focusing and refreshing count...");
        chrome.tabs.update(tab.id, { active: true });
         updateIcon();
    } else {
        console.log("Could not find Gmail tab. Creating one...");
        chrome.tabs.create({ url: getGmailUrl() });
         updateIcon();
       }
      });
    });



    function updateIcon(){

      var req = new XMLHttpRequest();
      req.addEventListener("readystatechange", function() …
Run Code Online (Sandbox Code Playgroud)

javascript notifications google-chrome google-chrome-extension

4
推荐指数
1
解决办法
8615
查看次数

警报在Chrome扩展程序的弹出窗口中无效

任何人都可以帮助我,找出我的问题.我已将我的网站设置为chrome扩展.当我安装扩展程序时,它会导航到一个弹出窗口,询问用户名和密码以及登录按钮.但是当我试图提醒用户在javascript中输入的用户名时,它无法正常工作.任何人请帮助我.这是什么原因?这是我的manifest.json

{
"name": "Calpine Extension",
"version": "1.0",
"description": "Log on to calpinemate",
"manifest_version": 2,
"browser_action": {
    "default_icon": "icon_128.png"
},
"background": {
    "persistent": false,
    "scripts": ["background.js"]
},

"browser_action": {
    "default_title": "Test Extension",
    "default_icon": "calpine_not_logged_in.png"
},
"permissions": [

  "*://blog.calpinetech.com/test/index.php",
  "alarms",
 "notifications"
  ],
   "web_accessible_resources": [
   "/icon_128.png"]

 }
Run Code Online (Sandbox Code Playgroud)

这是我的代码,它在安装时创建一个弹出窗口

      chrome.windows.create({url : "test.html"}); 
Run Code Online (Sandbox Code Playgroud)

这是我的test.html

<html>
<head>
    <script type="text/javascript">
        function log(){
            var uname=document.getElementById('name');
           alert(uname);
            }
    </script>
   </head>
   <body>
   <form name="userinfo" id="userinfo">
    username : 
    <input id="name" type="text" name="username"/><br><br>
    password :
    <input type="password" name="password"/><br><br>
    <input type="button" value="Log In" …
Run Code Online (Sandbox Code Playgroud)

javascript popupwindow google-chrome-extension

1
推荐指数
1
解决办法
3325
查看次数

如何在chrome扩展中设置弹出窗口的大小

嗨,我需要知道在 chrome 扩展中设置弹出窗口大小的语法这是我用来打开弹出窗口的语法。请帮我设置窗口的大小。我想减小大小。这是我的语法

chrome.windows.create({url : "userinfo.html"});
Run Code Online (Sandbox Code Playgroud)

请帮我

popupwindow google-chrome-extension window-resize

1
推荐指数
1
解决办法
1万
查看次数

如何在Chrome扩展程序中插入通知操作按钮?

嗨,我需要开发一个通知,其中2个按钮执行不同的操作.一个按钮是'MARK',另一个是'IGNORE'.当我点击MARK按钮时,它必须导航到一个网站.当我点击IGNORE时,通知框应该是隐形的,不应再显示了.我该怎么做?这是我的background.js

  var oldChromeVersion = !chrome.runtime;

  function getGmailUrl() {
    return "http://calpinemate.com/";
    }
       function isGmailUrl(url) {

       return url.indexOf(getGmailUrl()) == 0;
      }

    chrome.browserAction.onClicked.addListener(function(tab) {

     chrome.tabs.query({
    url: "http://calpinemate.com/*",
    currentWindow: true
    }, function(tabs) {
    if (tabs.length > 0) {
        var tab = tabs[0];
        console.log("Found (at least one) Gmail tab: " + tab.url);
        console.log("Focusing and refreshing count...");
        chrome.tabs.update(tab.id, { active: true });
         updateIcon();
    } else {
        console.log("Could not find Gmail tab. Creating one...");
        chrome.tabs.create({ url: getGmailUrl() });
         updateIcon();
    }
     });
     });
   function onInit() {
      console.log('onInit');
      updateIcon(); …
Run Code Online (Sandbox Code Playgroud)

javascript notifications google-chrome-extension

0
推荐指数
1
解决办法
8471
查看次数