how to get html2canvas working in ie8?

1.5k views Asked by At

I am trying to run this simple html2canvas code. It work great in Chrome, IE9, Firefox. But is not working in IE8

Code:

html2canvas($(#section), {
        onrendered: function (canvas) {            
            var img = canvas.toDataURL().replace(/^data[:]image\/(png|jpg|jpeg)[;]base64,/i, "");

            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "/Home/SaveDiv",
                data: "{'imageData': '" + img + "'}",
                dataType: "json",
                async: false,
                cache: false,
                success: function (msg) {
                },
                error: function (result) {
                    alert('error');

                }
            });
        }
        });

Is there a way I can get it working in IE8. I have heard about flashcanvas which I am not sure on how to use it.

Else, is there any other way I can capture <div> element in IE8.

2

There are 2 answers

1
Alexander Presber On BEST ANSWER

This is probably because html2canvas requires IE9 or higher, as stated here.

1
Typhomism On

I would recommend using a polyfill: heres a canvas one