我有一個名爲file.js的內容創建變量「found」。我想將varibale「found」的值發送到popup.html中的文本框中。在file.js中(我知道varible found正在工作,使用警報進行測試)。Chrome擴展消息傳遞 - 包含的代碼
chrome.extension.sendRequest({foundlinks: found}, function(response) {
console.log(response);
});
在Popup.html:
function pulllinks(){
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
document.getElementById("box").value = request.foundlinks;
sendResponse({});
});
而且在popup.html的形式:
<input type = "button" onclick="pulllinks();" name = "box" id="box" value = "Grab Links From Page" />
然而,它沒有做任何事情。有任何想法嗎?
謝謝!
哇,像一個魅力工作。感謝您的解釋。 – NoviceCoding 2011-05-02 16:55:09