如何在新标签中打开chrome.tabs.executeScript的结果?
window.addEventListener("click", whatever())
function whatever() {
chrome.tabs.executeScript(null, {
code: 'window.getSelection().toString();',
allFrames: true,
}, function(result) {
//open link 'https://'+result.toString() in new tab
});
};
答案 0 :(得分:0)
您可以使用带有_blank参数的window.open实现该目的:
...
}, function(result) {
var redirectWindow = window.open('https://'+result.toString(), '_blank');
redirectWindow.location;
//open link 'https://'+result.toString() in new tab
});
...