Google Chrome浏览器扩展程序 - 点击工具栏图标时打开新标签 [英] Google Chrome Extensions - Open New Tab when clicking a toolbar icon
问题描述
如何为Chrome添加图标的扩展程序,当您点击它时,它会打开一个包含本地网页的新标签(例如:f.html)?
我看到这个问题,但它并没有真正解释我应该在清单文件中添加什么...
谢谢。 / b>
对于新的chrome应用程序,这是不正确的。
更新的chrome具有manifest_version:2
的应用程序需要打开标签: > chrome.browserAction.onClicked.addListener(function(activeTab)
{
var newURL =http://www.youtube.com/watch?v=oHg5SJYRHA0;
chrome.tabs .create({url:newURL});
});
How can I create an extension for Chrome that adds an icon to the toolbar, and when you click it, it opens a new tab with some local web page (for example: f.html)?
I saw this question, but it doesn't really explains what should I add in the manifest file...
Thanks.
This is not true for newer chrome apps.
Newer chrome apps having manifest_version: 2 requires the tabs be opened as:
chrome.browserAction.onClicked.addListener(function(activeTab)
{
var newURL = "http://www.youtube.com/watch?v=oHg5SJYRHA0";
chrome.tabs.create({ url: newURL });
});
这篇关于Google Chrome浏览器扩展程序 - 点击工具栏图标时打开新标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!