IE支持Canvas标签
使用excanvas.js可以让IE支持Html5的canvas标签,具体用法如下:
1 <html>
2 <head>
3 <title></title>
4 <!--[if IE]>
5 <script type="text/javascript" src="../js/excanvas.js" οnlοad="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之后.
如果引入excanvas.js后仍不起效果,文件头若存在下面的语句,可以删除后在试一下
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">