简体   繁体   English

如何在MobileSafari中接收复制的图像?

[英]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. 我正在构建一个iOS网站,我正在尝试使用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: 当您稍后在文本字段中复制并粘贴它时,您可以获取以下URL:

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. 当您在相机胶卷,Facebook应用程序中复制图像,或选择并转到相同的文本字段(或textarea)时,粘贴选项不可用,但是当转到Mail.application时,粘贴选项可用,过去的形象。 So does anyone have a clue how to get the URL or binary data for a copied photo on an iPad? 那么有没有人知道如何在iPad上获取复制照片的URL或二进制数据?

Apple Documentation: Apple文档:

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

Example: 例:

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

This won't be possible for a website to do, as the javascript won't have direct access to any native elements. 这对于网站来说是不可能的,因为javascript将无法直接访问任何本机元素。

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. 但是, 如果你在本机应用程序,a-la phonegap中托管webview ...那么你可以通过处理本机代码中的粘贴,然后将其提供给webview来做一些事情。

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

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