Canvas.toDataURL()解决方法? [英] Canvas.toDataURL() Workaround?

查看:856
本文介绍了Canvas.toDataURL()解决方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,所以我的一个朋友请我帮助他创建一个画布绘画应用程序为他正在工作的移动网站。然而,他无法得到画保存到服务器。我做了一个小小的检查,似乎在浏览器的当前迭代(基于WebKIt IIRC),.toDataURL支持被随机抛出。是否有任何解决方法,允许通过POST请求发送画布数据?

Okay, so a friend of mine asked me to help him out with creating a canvas painting application for a mobile site he's working on. However, he was unable to get the "paintings" to save to the server. I did a little checking and it appears that in the current iteration of the browser (based on WebKIt IIRC), .toDataURL support was randomly thrown out. Is there any workaround for this that'll allow the canvas data to be sent via a POST request?

编辑


Browser- Netfront(R)Browser,NX v.1.0

Browser- Netfront(R) Browser, NX v.1.0

只是显示浏览器不支持它

It simply appears that the browser doesn't support it

canvas = document.getElementById('paint');
var imagedata = canvas.toDataURL();
var datafield = document.getElementById('dataurl');
datafield.value = imagedata;
document.forms["imagedatahold"].submit(); 

在要接收数据的文件中,querystring为空。

On the file that is to receive the data, the querystring is empty. This is not the case in any other browser as far as I can tell.

imagedata的值正以如下形式返回:

The value of "imagedata" is returning as:


资料:,

data:,


推荐答案

I用于在Android设备上运行Web应用程序时遇到问题。

问题是android没有一个 toDataURL 方法实现,所以我最终使用此实施: http://code.google.com/p/todataurl-png-js/

它可能有点慢,但它完成了工作。

I used to have a problem with a web app running on android devices.
The problem was that android didn't have a toDataURL method implementation, so I ended up using this implementation : http://code.google.com/p/todataurl-png-js/ .
It may be a bit slower, but it gets the job done.

这篇关于Canvas.toDataURL()解决方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆