最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Can we use canvas.toDataURL on IE7 and IE8? - Stack Overflow

programmeradmin3浏览0评论

I am using toDataURL() method of a canvas object. It works on IE9 and Chrome. But it is not supporting for IE7 and IE8. I found this link

.toDataURL/mit/9b59af148b7f14d41974cf318eed6f84c8c91062

It extends SVG to use toDataURL(). But in its implementation, it again uses canvas.toDataURL(). I am using Google's API (jquery.flot.js) for plotting all the graphs graphs. But it also uses canvas to plot the graph. So, SVG is not an option.

I there ever a way to use canvas.toDataURL() or something similar for IE7 and IE8.

Thanks in advance

I am using toDataURL() method of a canvas object. It works on IE9 and Chrome. But it is not supporting for IE7 and IE8. I found this link

https://github./sampula/SVG.toDataURL/mit/9b59af148b7f14d41974cf318eed6f84c8c91062

It extends SVG to use toDataURL(). But in its implementation, it again uses canvas.toDataURL(). I am using Google's API (jquery.flot.js) for plotting all the graphs graphs. But it also uses canvas to plot the graph. So, SVG is not an option.

I there ever a way to use canvas.toDataURL() or something similar for IE7 and IE8.

Thanks in advance

Share Improve this question edited Oct 4, 2011 at 15:26 Spudley 169k39 gold badges238 silver badges308 bronze badges asked Oct 4, 2011 at 9:41 Kumar KushKumar Kush 2,59411 gold badges32 silver badges43 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

IE7/8 does not support either Canvas or SVG.

It does however support VML, which is a vector language similar to SVG, and there are a number of javascript-based hacks for IE that use its VML functionality to emulate both Canvas and SVG in this older browser.

The most well known IE-Canvas hack is this one: http://code.google./p/explorercanvas/

I haven't spent much time with it myself, so I can't vouch for whether it can do specific functionality such as the toDataURL() method you're asking about, but if you can't do it with this, then it's unlikely to be possible at all.

I mentioned that there are similar tools for VML->SVG as well. If that's of interest to you, then you might want to look into this one: http://code.google./p/svg2vml/

Bear in mind that no matter how clever these hacks are, there is always a fundamental issue of performance. IE7/8's javascript interpreter is very slow by modern standards, and these are javascript-based tools trying to shoehorn very modern functionality into this old browser. They may well work, but don't try to do anything too clever with your canvas or SVG, or you'll kill the browser.

Finally, since you mentioned that you're using all this to draw graphs, I will point out the graphing module of the Raphael library. Raphael is a library which draws SVG graphics on all browsers (falling back to VML for IE). The graphing module provides all the usual graph types, wrapped in an extremely easy-to-use javascript API. And it is fully cross-browser patible -- it works on all desktop browsers out of the box from the latest Chrome and Firefox all the way back to IE6. If you're struggling with cross-browser patibility with the tools you're using now, you may want to switch to this library.

Hope that helps.

I have recently created an application in which I had to use toDataURL() but I was not able to find any way to do this in IE7/8. My application was an online image editor in which user was able to save the canvas contents. I believe there is not way we can use this method in IE7/8.

发布评论

评论列表(0)

  1. 暂无评论