Chrome Extension: How do I change the color of an HTML canvas using pure javascript? -
this question has answer here:
i'm working on building first google chrome extension have run problem.
i want extension make popup window when icon clicked. window display canvas thats color change, green, when button clicked.
i've tested code on websites such codepen , works fine not when run in chrome.
all of extension's files in same folder.
here html:
<!doctype html> <html> <head> <script src="popup.js"> </script> </head> <canvas id="canvs" style="border: 2px solid black"></canvas> <input type = "button" value = "color" onclick="colorchange()"> </html>
javascript (popup.js):
function colorchange(){ var can = document.getelementbyid("canvs"); can.style.backgroundcolor = "green"; }
any appreciated, thanks!
chrome extension not support inline javascript
you should
<input id="color" type = "button" value = "color" >
$("#color").click(function(){ // code });
// popup.js window.onload= function(){ var color = document.getelementbyid("color"); color.onclick = function(){ // code } }
Comments
Post a Comment