javascript 有没有办法在 IE7 或 IE8 中使用 Canvas?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10482570/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 10:02:29  来源:igfitidea点击:

Is there a way to use Canvas in IE7 or IE8?

javascripthtmlinternet-explorercanvas

提问by richa_pandey

Is there any workaround to use "Canvas" tag in IE7 and IE8 ? Pls let me know.

是否有任何解决方法可以在 IE7 和 IE8 中使用“Canvas”标签?请让我知道。

<input type="text" id="textSign" value="Sign" />
<input type="button" onclick="javascript:return changeSign();" value="changeSign" />
<canvas id="e" width="150" height="100"></canvas>
<script type="text/javascript">
var textSign = document.getElementById("textSign").value;
      function changeSign() {
             textSign = document.getElementById("textSign").value;
                    var canvas = document.getElementById("e");
                    var context = canvas.getContext("2d");
                    context.fillStyle = "#4c4c4c";
                    context.font = "30px Giddyup Std";
                    context.fillText (textSign , 20, 50);
                }
            </script>

回答by Adriano Repetti

Yes, there is a project to simulatethe canvas API on older versions of IE (7 and 8).

是的,有一个项目可以在旧版本的 IE(7 和 8)上模拟画布 API。

You can find it here, simply include the JavaScript file and go on as canvas was supported.

您可以在此处找到它,只需包含 JavaScript 文件即可继续操作,因为它支持画布。

Please note that is another layer of JavaScript code on the top of IE (and it's not famous to be very fast to parse JavaScript...)

请注意,这是在 IE 之上的另一层 JavaScript 代码(而且解析 JavaScript 的速度并不出名……)

回答by Denys Séguret

Yes there is : https://developers.google.com/chrome/chrome-frame/

是的,有:https: //developers.google.com/chrome/chrome-frame/

But as with any modern web technology, you'll have to make extensive tests while developping. And depending on your deployement location, you may be forbidden to use that (sysadmins still imposing IE7 may have strange requirements).

但与任何现代 Web 技术一样,您必须在开发过程中进行大量测试。并且根据您的部署位置,您可能会被禁止使用它(仍然强加 IE7 的系统管理员可能有奇怪的要求)。

回答by Denys Séguret

No. Canvas element is supported only in IE9.

不可以。Canvas 元素仅在 IE9 中受支持。