[英]Chrome Extension: Open tab without popup
I've used the following code in my popup.html file: 我在popup.html文件中使用了以下代码:
<script type="text/javascript" charset="utf-8">
chrome.tabs.create({'url': chrome.extension.getURL('page.html')}, function(tab) {
});
</script>
When I click the extension icon a new page does open, but so does an empty browser popup near the button. 当我单击扩展图标时,新页面会打开,但按钮附近的空浏览器弹出也会打开。 How do I open the tab without the empty popup appearing?
如何在没有出现空弹出窗口的情况下打开选项卡?
Thanks. 谢谢。
Popup is optional. 弹出窗口是可选的。 Just remove
default_popup
property from your manifest and then you can listen to icon click events in a background page or event page : 只需从清单中删除
default_popup
属性,然后您就可以在后台页面或事件页面中收听图标点击事件:
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.create({
'url': chrome.extension.getURL('page.html')
}, function(tab) {
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.