mercredi 1 avril 2015

Cause for the onload handler not responding

With the help of @Ken Fyrstenberg I've created a canvas and using drawImage() to draw an inline svg. Everything works okay but I'm stuck because of the below problem...


My problem is why isn't the onload handler not responding?? How do I fix it?



img2.onload = function() {
console.log("load");
}


I've narrowed down my problem. This is the part where I'm having issues:


jsFiddle



function createme() {
var test = $('<canvas />', { id : 'mycanvs' })
$('#album').append(test);

var svg2 = document.getElementById('sSource').innerHTML,
vms = test[0], //canvas
ctx2 = vms.getContext('2d');

svgToImage(svg2);

function svgToImage(svg2) {
var nurl = "data:image/svg+xml;utf8," + encodeURIComponent(svg2),
img2 = new Image;
alert("just before onload")
img2.onload = function() {
console.log("load"); // does not show
}
img2.src = nurl;
}
}

Aucun commentaire:

Enregistrer un commentaire