I\'m just curious to know if there\'s a better solution for doing this:
var img = new Image(); var div = document.getElementById(\'foo\'); img.onload = func
You can use this way:
var img = new Image(); var div = document.getElementById('theDiv'); img.onload = function() { div.appendChild(img); }; img.src = 'path/to/image.jpg';