For the poor soul, who spends the whole night trying to get the HTML5 feature to work with IE9, this is what I ended up using. I can partly get rid of it, because we are not too worried that IE users get a less user-friendly interface, and this is an internal application. But, YMMV.
Basically, Downloadify won't do anything when the return line is empty. Thus, due to the asynchronous nature of html2canvas rendering, nothing will happen the first time a user clicks. The second time (provided that the render is done if nothing continues until it is), the value will not be empty and the save will continue. I use the onCancel and onCoplete callbacks to clear the value again, to ensure that the next time the user tries to save, the image is not too out of date.
This does not take into account the event that the user in any way changes the DOM between clicks, but I do not know what can be done for this. I'm not at all proud of it, but IE is what it is. It works, which is enough at the moment.
var renderedPng = ''; var rendering = false; $('#snapshot').downloadify({ filename: function(){ return 'timeline.png'; }, data: function(){ if(!rendering && renderedPng == ''){ rendering = true; html2canvas($('#timeline'),{ onrendered:function(canvas){ renderedPng = canvas.toDataURL().replace('data:image/png;base64,',''); rendering = false; } }); } return renderedPng; }, onComplete:function(){ renderedPng = ''; }, onCancel: function(){ renderedPng = ''; }, dataType: 'base64', swf: '../static/bin/downloadify.swf', downloadImage: '../static/img/camera_icon_32.png?rev=1', width: 32, height: 32, transparent: true, append: false });
source share