不可能将html2canvas与ie8一起使用

Impossible to use html2canvas with ie8

本文关键字:一起 ie8 html2canvas 不可能      更新时间:2023-09-26

我想将html2canvas与ie8一起使用。我已经搜索并找到了使用html2canvas的flashcanvas。但是,我在文件 html2canvas.js 中遇到了问题。每次调用函数 loadPseudoElement 时:

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);
}

"var style = window.getComputedStyle(element, type),"行中出现错误。

显然,getComputedStyle 不是由 ie8 处理的。我试过这个:

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

但它仍然不起作用。

我调用html2canvas和flashcanvas的JS代码是:

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;
}

你能帮帮我吗?

谢谢。

html2canvas依赖于IE8或更低版本不支持的许多东西,你会发现它几乎不可能让它在IE8上运行。