我正在开发chrome扩展程序。此时,我正在尝试在新窗口内使用innerHTML更改段落标记。基本上,当用户选择右键单击时,我要创建新窗口并更改html代码。到目前为止,这是我的代码。
function createNewWindowWhenRightClickTrigger() {
chrome.windows.create(
{
url: "newpage.html",
type: "popup",
width: 560,
height: 800
},
function(wd) {
chrome.tabs.getSelected(null, function(tab) {
var tablink = tab.url;
var innerH = tab.url.getElementById("selected")
innerH.innerHTML = "Hi jjoj";
console.log(tab);
});
}
);
}
这是 newpage.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
</head>
<body>
<div id="textSelect">
<h1>Summary: </h1>
<p id="selected"></p>
</div>
</body>
</html>