开发者

Pasting non-text data into browser-based apps

开发者 https://www.devze.com 2023-01-03 07:36 出处:网络
Imagine I want a user to be able to copy-paste a selection of pixels from MSPaint into a browser-based app. Is this possible using JavaScript in any current 开发者_C百科browsers? Will it become possib

Imagine I want a user to be able to copy-paste a selection of pixels from MSPaint into a browser-based app. Is this possible using JavaScript in any current 开发者_C百科browsers? Will it become possible in HTML5? If not, is it feasible using something like Flex/Silverlight, or is it simply not possible at this time, and you'd have to save a file and manually upload it?

update: sounds like HTML5 should allow it, but that's a way in the future to be genuinely useful. Some suggestions of Java applets and Flash are mentioned, probably Flash would be preferable since parts of the web-client would probably use Flex anyway... I'd rather not have requirement for Java and Flash in my site.


There's a very thorough examination of this prior question: Wysiwyg with image copy/paste. It discusses possibly coming behavior in HTML5, as well as Flash and Java applet solutions that interact with the clipboard, and which you can then tie into JavaScript.


Questioner asked about Zeroclipboard's applicability. So, look at the file ZeroClipboard10.as and you'll see the click handler supports two data formats:

private function clickHandler(event:Event):void {
    // user click copies text to clipboard
    // as of flash player 10, this MUST happen from an in-movie flash click event
    Clipboard.generalClipboard.clear();
    Clipboard.generalClipboard.setData(ClipboardFormats.TEXT_FORMAT, clipText);
    Clipboard.generalClipboard.setData(ClipboardFormats.HTML_FORMAT, clipText);
    ExternalInterface.call( 'ZeroClipboard.dispatch', id, 'complete', clipText );
}

The reference for ActionScript's ClipboardFormats constant indicates one of the formats is a BITMAP_FORMAT. So I think that's a pretty good start.

0

精彩评论

暂无评论...
验证码 换一张
取 消