Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to receive a copied image in MobileSafari?

I'm building an iOS website, and I'm trying to get the recently copied image using JavaScript.

When you hold your finger on a photo in a website a menu will pop-out with the option to Save the image or Copy. When you press copy and paste it later in a text-field, you can get the URL with:

pasteEvent.clipboardData.getData('text/uri-list');

When you copy an image in the camera roll, facebook application, or by selecting and you go to the same text-field (or textarea) the paste option is not available, however when going to the Mail.application the Paste option is available and pasts the image. So does anyone have a clue how to get the URL or binary data for a copied photo on an iPad?

Apple Documentation:

http://developer.apple.com/library/safari/#documentation/appleapplications/Conceptual/SafariJSProgTopics/Tasks/CopyAndPaste.html

Example:

http://codebits.glennjones.net/editing/getclipboarddata.htm

like image 987
Mark Avatar asked May 12 '12 08:05

Mark


1 Answers

This won't be possible for a website to do, as the javascript won't have direct access to any native elements.

if however, you are hosting a webview in a native application, a-la phonegap ... then you may be able to do something here by handling the paste in native code, and then making it available to the webview.

like image 61
Joel Martinez Avatar answered Sep 21 '22 03:09

Joel Martinez