Google Chrome 扩展程序 - 单击工具栏图标时打开新标签页 [英] Google Chrome Extensions - Open New Tab when clicking a toolbar icon

查看:27
本文介绍了Google Chrome 扩展程序 - 单击工具栏图标时打开新标签页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为 Chrome 创建一个扩展程序,在工具栏中添加一个图标,当您单击它时,它会打开一个包含一些本地网页的新选项卡(例如:f.html)?

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...

推荐答案

这不适用于较新的 chrome 应用程序.

This is not true for newer chrome apps.

具有 manifest_version: 2 的较新 chrome 应用要求标签打开为:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆