2013-11-29 60 views
1

我需要知道如何在安装扩展程序时显示弹出窗口。我试图问的是,当我安装扩展程序时,在那一刻本身,应该打开一个弹出窗口询问用户名和密码。我该怎么做?我不熟悉这个问题。 这里是我的manifest.json如何在安装Chrome扩展程序时显示弹出窗口

{ 
"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": "Calpine Extension", 
    "default_icon": "calpine_not_logged_in.png"  
}, 
"permissions": [ 

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

} 
+1

你'browser_action'两次在你的清单,你应该只有一次。 – abraham

+0

另请参阅http://stackoverflow.com/q/29331302/32453 – rogerdpack

回答

1

试试这个:

chrome.runtime.onInstalled.addListener(function (details) { 

    if (details.reason == "install") { //reason (enum of "install", "update", or "chrome_update") 
     //Show the PopUp 
    } 
}); 

http://developer.chrome.com/extensions/runtime.html#event-onInstalled

+0

嗨,谢谢marc,您的回复 – user1991

+0

如何声明原因为枚举? – user1991

+0

我不确定我是否理解你的正确。属性“原因”的可用“值”为:install,update或chrome_update。 (请参阅文档) – Marc

相关问题