【问题标题】:HTML5 Canvas Program Cannot draw image on Internet Explorer 8 BrowserHTML5 Canvas 程序无法在 Internet Explorer 8 浏览器上绘制图像
【发布时间】:2015-11-10 10:17:10
【问题描述】:

我创建了一个 html5 画布程序,将图像复制到画布对象中。将透明背景图像颜色更改为蓝色。该程序在 Firefox 和 Chrome 上正确运行。但我想在 Internet Explorer 8 上运行该程序。

程序:

<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>

【问题讨论】:

标签: jquery html internet-explorer-8 html5-canvas


【解决方案1】:

HTML5 canvas 标签不支持 Internet Explorer 8。它只支持 IE9 及更高版本。

来源

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

看看explorercanvas虽然

https://github.com/arv/explorercanvas

要包含它,请添加此条件注释

<!--[if lte IE 8]><script type="text/javascript" src="excanvas.js"></script><![endif]-->

【讨论】:

  • 赞成正确答案,但这是一个重复的问题。 ;-)
猜你喜欢
  • 1970-01-01
  • 2011-08-28
  • 2011-02-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-02-07
  • 2014-10-20
相关资源
最近更新 更多