我创建了一个谷歌浏览器扩展程序,可以在新标签页中打开上一页,但是使用我当前的代码,它只会执行并创建一个新的空白标签页。如何使历史记录返回按钮起作用?
清单
{
"manifest_version": 2,
"name": "Back",
"description": "Opens the Previous Page in a New Tab",
"version": "1.0",
"background": {
"scripts": ["popup.js"]
},
"browser_action": {
"default_icon": "icon.png",
"default_title": "Back"
},
"permissions": [
"tabs",
"history"
]
}
和Popup.js
// Called when the user clicks on the browser action.
chrome.browserAction.onClicked.addListener(function(tab) {
var action = window.history.back(1);
chrome.tabs.create({ url: action });
});