画布不在ie8浏览器中工作

时间:2014-03-09 17:35:11

标签: javascript canvas html5-canvas kineticjs canvasjs

  • 我的画布不在ie8中工作,包括explorer canvas js文件和 在我的HTML中包含脚本标签...我从这个链接下载 你可以https://code.google.com/p/explorercanvas/downloads/list 告诉我如何修复这个错误...在下面提供我的代码......或者有办法修复错误

http://jsfiddle.net/fHmA8/1/

<!--[if IE]><script type="text/javascript" src="../excanvas.js"></script><![endif]-->
<!--[if IE]><script type="text/javascript" src="http://www.craftygnome.com/fixes/excanvas.js"></script><![endif]-->
var animate = function() {
        canvas.width = canvas.width;    //clear canvas

        percent += STEP_PERCENT;    //increase percentage
        var deg = percent / 100 * deg360;   //calculate current position in radians

        drawArc('#aaa', radius, deg360, null, true);    //draw grey background (last parameter - true - draw shadow)
        drawArc('#0e728e', radius, deg);                //draw light blue
        for (var i = 0, n = Math.floor(deg / deg60); i < n; i++) {  //draw segments (as I understand segment drawing works not exactly as you want so you can delete this code)
            var from = i * deg30 + deg1;
            var to = from + deg30 - deg1 * 2;
            drawArc('#250696', radius, to, from);
        }

        if (percent >= 100) {
            //done
        } else {
            setTimeout(animate, STEP_DELAY);    //next step in STEP_DELAY ms
        }
    }

1 个答案:

答案 0 :(得分:1)

您可能需要根据创建时间来初始化画布。你可以通过调用这些行来实现这一点 -

在脚本顶部获取“canvas”元素后:

// initialize if excanvas
if (typeof G_vmlCanvasManager !== 'undefined')
    G_vmlCanvasManager.initElement(canvas);

// now this should work
var ctx = canvas.getContext('2d');

... continue code here...