Question

I would like to use html2canvas with ie8. I have searched and found flashcanvas to use html2canvas. But, I have a problem in the file html2canvas.js. Everytime the function loadPseudoElement is called :

function loadPseudoElement(element, type) {
    var style = window.getComputedStyle(element, type),
    content = style.content;
    if (content.substr(0, 3) === 'url') {
        methods.loadImage(_html2canvas.Util.parseBackgroundImage(content)[0].args[0]);
    }
    loadBackgroundImages(style.backgroundImage, element);
}

an error appears in the line "var style = window.getComputedStyle(element, type),".

Apparently, getComputedStyle is not handle by ie8. I have tried this :

var style = null;
if (window.getComputedStyle) {
    style = window.getComputedStyle(element, type);
}
else {
    style = element.currentStyle;
}
var content = style.content;

but it's still not working.

My JS code to call html2canvas and flashcanvas is :

function test(){

    html2canvas($('#contentBody'), {
        onrendered: function (canvas) {
            if (typeof FlashCanvas != "undefined") {
                FlashCanvas.initElement(canvas);
            }
            var img = canvas.toDataURL("image/png");
            var newImg = window.open(img);
        }     
    });
    return false;
}

Could you help me, please?

Thank you.

Was it helpful?

Solution

html2canvas relies on so many things that IE8 or below doesn't support that you are gonna find it next to impossible to get it working on IE8.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top