IE支持canvas标签

使用excanvas.js可以让IE支持Html5的canvas标签,具体用法如下:

 1 <html>
 2 <head>
 3     <title></title>
 4     <!--[if IE]>
 5 <script type="text/javascript" src="excanvas.js" onload="explorercanvasload"></script>
 6     <![endif]-->
 7 </head>
 8     <body>
 9         <canvas id="canvas" width="400" height="300"></canvas>
10         <script type="text/javascript">
11             window.onload = function() {
12                 var ctx = document.getElementById("canvas").getContext("2d");
13                 ctx.fillRect(10, 10, 20, 20);
14             };
15         </script>
16     </body>
17 </html>

需要注意一点,使用时一定要在onload之后.

示例请见:canvasexplorer-box2d示例 

posted @ 2012-11-10 10:08  mytree  阅读(4741)  评论(0编辑  收藏  举报