【问题标题】:Impossible to use html2canvas with ie8无法将 html2canvas 与 ie8 一起使用
【发布时间】:2013-11-08 04:58:55
【问题描述】:

我想在 ie8 中使用 html2canvas。我已经搜索并发现使用 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;
}

你能帮帮我吗?

谢谢。

【问题讨论】:

    标签: javascript internet-explorer-8 html2canvas


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2013-09-05
      • 1970-01-01
      • 2013-08-10
      • 1970-01-01
      • 2012-04-29
      • 2013-10-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-07
      相关资源
      最近更新 更多