Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 - Read the Clipboard?

Tags:

html

Is it possible with HTML 5 to read the clipboard (without using Java)?

like image 287
Peter Avatar asked Oct 09 '10 09:10

Peter


People also ask

How do you read the clipboard?

Look for a clipboard icon in the top toolbar. This will open the clipboard, and you'll see the recently copied item at the front of the list. Simply tap any of the options in the clipboard to paste it into the text field. Android does not save items to the clipboard forever.

Can a website read your clipboard?

This is because websites scripts can erase and replace what you currently have in your clipboard (data loss issue) and they can read whatever you have in your clipboard (security and privacy issue); as such, you should grant access with caution.

How do you use clipboard in browser?

Smart buttons that allow you to copy URL's directly from the search bar to the clipboard How to Use: 1. Highlight the text you wish to copy. 2. Right click and select "Copy" or press on CTRL+C (Windows) / CMD+C (MAC).

What is clipboard API?

The Clipboard API provides the ability to respond to clipboard commands (cut, copy, and paste) as well as to asynchronously read from and write to the system clipboard.


2 Answers

Perhaps the HTML5 Core spec doesn't provide an API for accessing the clipboard, but one of the APIs in the HTML5 family of APIs does. It's called "Clipboard API and Events," and its currently (as of July 2011) a Working Draft. You can find the spec here:

http://www.w3.org/TR/clipboard-apis/

As for implementations, well, I couldn't find one just yet.

Update: As of Dec 2012, this API is still a working draft (dated Feb 2012). There still do not appear to be any working implementations, just a Flash-based workaround for text.

like image 103
james.garriss Avatar answered Oct 11 '22 07:10

james.garriss


Yes you can use pure JavaScript for this, assuming a modern browser that implements the Clipboard API such as Google Chrome.Chrome Frame is available for IE support and I assume that Firefox will implement the Clipboard API fairly soon. You can only read clipboard data from paste events (such as Ctrl+V), but from that you can read binary data such as image data.

HTML Clipboard API jQuery Plugin and demo. This demo requires the Chrome browser.

like image 33
Daniel X Moore Avatar answered Oct 11 '22 05:10

Daniel X Moore