我正在构建一个铬应用程序,它将简单地打开一个链接,例如,在chrome中的一个新选项卡中的"http://www.cnn.com/“。
我的manifest.json中有以下代码
{
"manifest_version": 2,
"name": "CNN",
"version": "2.1",
"permissions": ["webview", "pointerLock", "geolocation", "videoCapture"],
"app": {
"background": {
"scripts": ["main.js"]
}
}
}这就是我在main.js中所做的:
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('http://www.cnn.com/', {
});
});我也试过,
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create({ "url": "http://cloudsupport.neonova.net/home" });
});以及:
chrome.app.runtime.onLaunched.addListener(function(tab) {
chrome.app.tab.create({ "url": "http://cloudsupport.neonova.net/home" });
});PLease帮助。
谢谢
发布于 2014-03-27 05:04:35
不管怎么说,我试过window.open,它像一种魅力一样分叉:
'use strict';
chrome.app.runtime.onLaunched.addListener(function() {
window.open("https://google.com/");
});所以这对你也有用。
发布于 2015-04-22 13:02:20
从铬42开始,chrome.browser可能有助于:
chrome.app.runtime.onLaunched.addListener(function() {
chrome.browser.openTab({
url: 'https://google.com/'
});
});发布于 2014-03-27 05:08:48
参考: https://developer.chrome.com/extensions/tabs#method-create
var options= { url: "http://cloudsupport.neonova.net/home" };
chrome.app.runtime.onLaunched.addListener(function() {
chrome.tabs.create(options);
});然后在manifest.json。添加此权限。
...
"permissions": ["tabs","webview", "pointerLock", "geolocation", "videoCapture"]
...https://stackoverflow.com/questions/22678489
复制相似问题