Html5-测试Canvas

 

 1 <style><!--
 2 #container{
 3     background-color:#C7C7C7;
 4 }
 5 --></style>
 6 <div id="container">&nbsp;</div>
 7 <p>
 8 <script type="text/javascript">// <![CDATA[
 9 window.addEventListener("load",eventWindowLoaded,false);
10     function eventWindowLoaded(){
11         canvasApp();
12     }
13     function canvasApp(){
14         document.getElementById("container").innerHTML="<canvas id='canvas_one' width='500' height='300'>浏览器不支持Html5 Canvas</canvas>";
15         var theCanvas=document.getElementById("canvas_one");
16         if(!theCanvas||!theCanvas.getContext){return;}
17         var context=theCanvas.getContext("2d");
18         function drawScreen(){
19             context.fillStyle="#FF0000";
20             context.fillRect(0,0,150,75);
21         }
22         drawScreen();
23     }
24 // ]]></script>
25 </p>

 

posted @ 2016-01-09 00:00  alexywt  阅读(471)  评论(0编辑  收藏  举报