let drawCanvas = document.getElementById('but1');
let theInputColor = document.getElementById("colorPicker").value;
drawCanvas.onclick = function(undefined){
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
chrome.tabs.executeScript(tabs[0].id, { file: "canvasDrawing.js"}, function(){
chrome.tabs.sendMessage(tabs[0].id, theInputColor);
});
});
};
....function drawLine(context, x1, y1, x2, y2) {
context.beginPath();
context.strokeStyle = theInputColor;
context.lineWidth = 3;
context.moveTo(x1, y1);
context.lineTo(x2, y2);
context.stroke();
context.closePath();
};
我需要 chrome.tabs.onMessage 响应吗?
感谢回复评论,我能够找出解决我的问题的方法。虽然这两种方法都有效,但我发现使用存储 API 来发送多条消息要好得多。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句