I'm developing a chrome extension to get a table from two open tab and show them in one new tab. Up to now, the following extension gets the table from one tab, but shows the result in the popup.html, how could I show it in a new tab?
manifest.json:
{
"name": "Tables",
"description": "Tables",
"version": "1.0",
"manifest_version": 2,
"permissions": ["tabs", "<all_urls>"],
"browser_action": {
"default_popup": "popup.html"
}
}
popup.html:
<!DOCTYPE HTML>
<html>
<head></head>
<title></title>
<body>
<div id="contentId">-</div>
<script type="text/javascript" src="popup.js"></script>
</body>
</html>
popup.js:
function table_content (results){
contents = results;
document.querySelector("#contentId").innerHTML = "<div>" + contents + "</div>";}
chrome.tabs.query({active: true}, function(tabs) {
var tab = tabs[0];
chrome.tabs.executeScript(tab.id, {
code: 'document.getElementById("appointmentTable").innerHTML'
}, table_content);
});