【发布时间】:2016-03-10 18:15:18
【问题描述】:
我正在开发一个 Chrome 扩展程序,其目标是在后台访问网站并显示其中的特定值打开特定选项卡。
这是我的popup.html:
<!doctype html>
<html>
<head>
<title>Notification Analyzer</title>
<script src="popup.js"></script>
</head>
<body>
<h1>Current Notifications</h1>
<a id="myLink" href ="https://website.com/notify/index.php"></a>
</body>
</html>
还有我的popup.js:
a = document.getElementsByClassName('notificationArea').item('span').childNodes[6].textContent; // this is the value which I want to display on click of the extension icon
window.onload = function() {
document.getElementById("myLink").innerHTML=a;
} // Here, trying to add the value to the popup.html element
如果我尝试在特定网站选项卡上弹出警告框,它会起作用。但在网站选项卡未打开时不在后台。
这里有两个问题:
如何使扩展程序能够在后台访问网站内容?
如何在 popup.html 中显示来自 popup.js 的 javascript 内容
【问题讨论】:
标签: javascript html google-chrome-extension