我使用canvas元素与text一起绘制曲线.它在chrome,Firefox,IE 9中运行良好.但是在IE 8,7中这不起作用.显示错误如:
SCRIPT438: Object doesn’t support property or method ‘getContext’
在IE 9以下版本中.
我在谷歌搜索然后我发现Excanvas.js会找出这个问题,但没有使用excanvas.js,我仍然得到同样的错误.
请帮我.
谢谢.
`
`
我的html画布代码:
我的js代码:
function drawTextAlongArc(context,str,centerX,centerY,radius,angle)
{
var len = str.length,s;
context.save();
context.translate(centerX,centerY);
context.rotate(-1 * angle / 2);
context.rotate(-1 * (angle / len) / 2);
for(var n = 0; n < len; n++) {
context.rotate(angle / len);
context.save();
context.translate(0,-1 * radius);
s = str[n];
context.fillText(s,0);
context.restore();
}
context.restore();
}
var canvas = document.getElementById('myCanvas'),context = canvas.getContext('2d'),centerX = canvas.width / 2,centerY = canvas.height + 40,angle = Math.PI * 0.8,radius = 250;
context.font = 'bold 30pt Ubuntu';
context.textAlign = 'center';
context.fillStyle = 'orange';
context.strokeStyle = '#336699';
context.lineWidth = 10;
drawTextAlongArc(context,'Sustainable Skill Solutions',angle);
// draw circle underneath text
context.arc(centerX,radius +70,2 * Math.PI,false);
context.stroke();