desktopCapture问题(chrome扩展名)

时间:2017-04-21 15:00:29

标签: javascript google-chrome-extension

我尝试为抓取屏幕的chrome创建扩展程序。但我发现了一个问题(在我看来)。 chooseDesktopMedia显示选择屏幕的对话框并立即隐藏。

的manifest.json:

{
  "manifest_version": 2,

  "name": "desktopCapture",
  "description": "User testing application",
  "version": "1.0",

  "browser_action": {
    "default_icon": "icon.png",
    "default_popup": "popup.html"
  },

  "permissions": [
    "desktopCapture"
  ]
}

popup.js

document.querySelector('#start').addEventListener('click', function(event) {
  chrome.desktopCapture.chooseDesktopMedia(
      ["screen", "window"],
      function(id) {
        console.log("id",id);
      });
});

popup.html

<!DOCTYPE html>
<html>
<head>
  <title>Desktop capture</title>
</head>
<body>
  <button id="start">Start</button>
  <script src="popup.js"></script>
</body>
</html>

0 个答案:

没有答案