0

i'm created an html5 canvas program that copying a image into canvas object. that change transparent background image color to blue color. that program correctly run on Firefox and Chrome. but i want to run that program an Internet Explorer 8.

Program :

<body>
<img id="my_img" src="https://cdn0.iconfinder.com/data/icons/classic-cars-by-cemagraphics/512/red_512.png" alt="The Image">
<canvas id="myCanvas" style="border:3px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
document.getElementById("my_img").onload = function() {
    var img = document.getElementById("my_img");
    var c = document.getElementById("myCanvas");
    var ctx = c.getContext("2d");
 c.width=img.width;
 c.height=img.height;
 ctx.rect(0,0,c.width,c.height);
 ctx.fillStyle="blue";
 ctx.fill(); 
 ctx.drawImage(img, 0, 0);          
};
</script>
</body>
  • 1
    IE 8 doesn't support Canvas. you can use You can use explorercanvas to add canvas functionality to IE8. here's the link https://github.com/arv/explorercanvas – Sushil Aug 17 '15 at 17:19
  • 2
    possible duplicate of [How can I use the HTML5 canvas element in IE?](http://stackoverflow.com/questions/1332501/how-can-i-use-the-html5-canvas-element-in-ie) – Alon Amir Aug 17 '15 at 17:21

1 Answers1

1

The HTML5 canvas tag doesn't support Internet Explorer 8. It only supports IE9 and up.

Source

http://www.w3schools.com/html/html5_canvas.asp

Take a look at explorercanvas though

https://github.com/arv/explorercanvas

To include it, add this conditional comment

<!--[if lte IE 8]><script type="text/javascript" src="excanvas.js"></script><![endif]-->
Richard Hamilton
  • 25,478
  • 10
  • 60
  • 87