这是我的尝试。我能想到的最好的方法就是在chrome扩展程序中打开链接。我希望它能在新标签页中打开。
<!DOCTYPE html>
<html>
<head>
<title></title>
<link href="css/style.css" rel="stylesheet"/>
<script type="text/javascript">
var items = [];
var background;
function init() {
background = chrome.extension.getBackgroundPage();
items = background.items;
createItemTable();
}
function createItemTable() {
var content = document.getElementById("content");
var list = document.createElement("div");
list.setAttribute("class", "list");
content.appendChild(list);
for (x in items) {
var item = items[x];
var link = document.createElement("a"); // create the link
link.setAttribute('href', "'" + item["link"] + "'"); // set link path
link.setAttribute("onclick", "openTab('" + item["link"] + "');");
var titleNode = document.createElement("div");
titleNode.setAttribute("class", "title");
titleNode.appendChild(document.createTextNode(item["title"]));
link.appendChild(titleNode);
result.appendChild(link);
list.appendChild(result);
}
}
</script>
</head>
<body onload="init();" onunload="background.updateBadge();">
<div id="content"></div>
</body>
</html>
答案 0 :(得分:6)
试
link.setAttribute('target','_blank');