Chrome Extension: How do I change the color of an HTML canvas using pure javascript? -


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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -