Pass an image to a canvas with dataurl

I am trying to make an image being passed to a canvas from a weburl.
The code has been taken from this [1] which is accepted but for some reason it does not work on me on firefox or chrome.

Any ideas?

Here you are:

var myCanvas = document.getElementById('my_canvas_id');
var ctx = myCanvas.getContext('2d');
var img = new Image;
img.onload = function(){
  ctx.drawImage(img,0,0); // Or at whatever offset you like


Source: html5

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.