Chrome扩展程序:onclick扩展图标,在新标签页中打开popup.html [英] Chrome Extension: onclick extension icon, open popup.html in new tab
问题描述
我创建了一个Chrome扩展,并设法使用 window.open
打开 popup.html
文件。然而我想打开它在一个新的标签,我已经尝试了很多不同的方式,包括:
I have created a chrome extension and managed to open the popup.html
file using window.open
. however I want to open it in a new tab, I've tried lots of different ways including:
<script type="text/javascript" language="JavaScript">
chrome.tabs.create('url': 'popup.html');
我只是把代码放在错误的地方,还是完全是错误的代码?
Am I just placing the code in the wrong place or is it the wrong code altogether?
推荐答案
为什么要在新选项卡中打开popup.html?你应该为此创建一个不同的页面。无论如何,如果你想打开popup.html,在一个新的标签中,你需要传递扩展名的URL。
why would you want to open the popup.html in a new tab? You should create a different page for that. Anyways, if you want to open up the popup.html, in a new tab, you would need to pass in the extension url.
http://code.google.com/chrome/extensions/extension.html#method-getURL
chrome.tabs.create({'url': chrome.extension.getURL('popup.html')}, function(tab) {
// Tab opened.
});
这篇关于Chrome扩展程序:onclick扩展图标,在新标签页中打开popup.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!