无法在Google Chrome扩展程序中创建新窗口

时间:2017-05-10 21:11:09

标签: javascript jquery google-chrome-extension

我试图在我的popup.html页面上创建一个按钮,通过单击按钮在浏览器上创建另一个窗口。当我点击按钮但没有发生任何事情。我想我的eventPage设置不正确。所以回顾一下,我想在我的popup.html页面上创建一个新的窗口,其中包含一个名为tabby.html的预先存在的html页面

POPUP.HTML

<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="js/script.js"></script>
</head>

<body>
    <div class="button tabby" id="create_button">Create Tab</div>
</body> 

</html>

eventPage.js

function create() {
        var createPage = {
            "url": "tabby.html"
            , "type": "popup"
            , "top": 5
            , "left": 5
            , "width": screen.availWidth
            , "height": screen.availHeight
        };
        chrome.windows.create(createPage, function () {});
}

document.addEventListener('DOMContentLoaded', function () {
    $("#create_button").addEventListener('onclick', create);
});

的manifest.json

{
    "name": "name"
    , "version": "0.0.1"
    , "manifest_version": 2
    , "description": "DESC"
    , "icons": {
        "128": "img/icon128.png"
        , "48": "img/icon48.png"
        , "16": "img/icon16.png"
    }
    , "browser_action": {
        "default_icon": "img/icon48.png"
        , "default_title": "name"
        , "default_popup": "popup.html"
    }
    , "background": {
        "scripts": ["js/eventPage.js"]
        , "persistance": false
    }
    , "web_accessible_resources": ["tabby.html"]
    , "permissions": [
          "http://*/*"
    , "https://*/*"
        , "tabs"
  ]
}

0 个答案:

没有答案