Whenever I try to run this, I get a type error in chrome: Code Update
// Get the drawing canvas
canvas = $('#drawing');
context = canvas[0].getContext('2d');
function resizeCanvas() {
canvas.attr({'width' : $(window).width()});
canvas.attr({'height' : $(window).height() - 158});
var dataURL = canvas[0].toDataURL('image/png');
context.drawImage(dataURL, 0, 0);
}
$(window).resize(function() {
resizeCanvas();
}); resizeCanvas();
// Various event handlers after this.
Why!?
drawImagetakes an image or a canvas reference, you are passing it a string.For instance:
You could try:
Or