Example of how ExCanvas is to be used for getting the functionality of HTML 5 Canvas in Microsoft Internet Explorer. ExCanvas is an open source JavaScript library which is available freely. First embed this line in HEAD tag of the web page : <!--[if IE]><script type="text/javascript" src="...excanvas.js"></script><![endif]--> Second Step: <script language="JavaScript" type="text/javascript"> /*<![CDATA[*/ window.onload = function() { var c = document.createElement('canvas') ; c.setAttribute('id', 'canvas') ; c.setAttribute("width" , '200') ; c.setAttribute("height" , '200') ; if (typeof(G_vmlCanvasManager) != 'undefined') { c = G_vmlCanvasManager.initElement(c); } document.body.appendChild(c) ; ctx = document.getElementById('canvas').getContext('2d'); ctx.lineWidth = 5 ; ctx.beginPath() ; ctx.moveTo(50,50) ; ctx.lineTo(100,100) ; ctx.closePath() ; ctx.stroke() ; }; /*]]>*/ </script> |