日期:2014-05-16 浏览次数:20301 次
<!DOCTYPE html> <html> <head> <title>excanvas demo</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script type="text/javascript" src="excanvas.js"></script> </head> <body> <canvas id="canvas"></canvas> <script type="text/javascript"> window.onload = function(){ var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); ctx.fillStyle = "red"; ctx.beginPath(); ctx.moveTo(30, 30); ctx.lineTo(150, 150); ctx.quadraticCurveTo(60, 70, 70, 150); ctx.lineTo(30, 30); ctx.fill(); } </script> </body> </html>
var canvas=document.createElement(”canvas”); if(canvas.getContext){ alert(”support getContext()”); }
var els = doc.getElementsByTagName(”canvas”); for (var i = 0; i < els.length; i++) { if (!els[i].getContext) { this.initElement(els[i]); } }
$(function(){ var canvas=document.createElement(”canvas”); document.body.appendChild(canvas); if($.browser.msie){ canvas=window.G_vmlCanvasManager.initElement(canvas); } if(canvas.getContext){alert(”support”);} });