简体   繁体   English

Canvas.toDataURL()解决方法?

[英]Canvas.toDataURL() Workaround?

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. 我做了一点检查,似乎在浏览器的当前版本(基于WebKIt IIRC)中,.toDataURL支持被随机丢弃了。 Is there any workaround for this that'll allow the canvas data to be sent via a POST request? 是否有任何解决方法可允许通过POST请求发送画布数据?

Edit: 编辑:

Browser- Netfront(R) Browser, NX v.1.0 浏览器-Netfront(R)浏览器,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(); 

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. 据我所知,在任何其他浏览器中都不是这种情况。

The value of "imagedata" is returning as: “ imagedata”的值返回为:

data:, 数据:,

I used to have a problem with a web app running on android devices. 我曾经在android设备上运行的网络应用有问题。
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/ . 问题是android没有toDataURL方法的实现,所以我最终使用了该实现: http : //code.google.com/p/todataurl-png-js/
It may be a bit slower, but it gets the job done. 它可能会慢一些,但是可以完成工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM