我有一个扩展示例,弹出窗口作为新选项卡打开。
所以,现在我想在同一个 Chrome 事件标签页中打开这个弹出窗口,如下所示:
我已经尝试了几种方法,但直到现在都没有成功。
PS:我使用的是 Google Chrome V.50
这是在新标签页中打开弹出窗口的代码:
manifest.json
{
"background": {
"scripts": ["action.js"],
"persistent": false
},
"name": "W3C cheatsheet",
"version": "0.1",
"manifest_version": 2,
"description": "Show the W3C cheatsheet on a popup",
"icons": { "48": "favicon.png" },
"browser_action": {
"default_icon": "favicon.png"
},
"permissions": ["http://*/", "tabs"]
}
action.js
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.create({'url': chrome.extension.getURL('w3c.html'), 'selected': true});
});
popup.html(在本例中为 w3c.html)
<html>
<head>
<script>
</script>
<style>* {margin: 0; padding: 0; border: 0;}</style>
</head>
<body>
<iframe src="https://www.w3.org/2009/cheatsheet/" width="450" height="500"></iframe>
</body>
</html>
最佳答案
已解决:
在 manifest.json 中:
"browser_action": {
"default_popup": "w3c.html"
},
关于javascript - 如何在没有新标签的情况下打开 popup.html?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37232705/