0
  • 我的画布在 ie8 中不起作用我包含资源管理器画布 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
        }
    }
4

1 回答 1

0

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

在脚本顶部获取“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...
于 2014-03-10T06:50:40.943 回答