Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read clipboard data in cross browser?

Possible Duplicates:
Copy / Put text on the clipboard with FireFox, Safari and Chrome
How to Copy to Clipboard in JavaScript?

Hi ,

scenario: I copied some content (either from notepad or word) and want to paste it in my iframe. On before pasting i want to manipulate the clipboard content. In IE i can do it with window.clipboardData.getData("Text"); How to read the clipboard data in other browsers (FF/chrome and safari)

like image 390
Jagadesh Avatar asked Apr 05 '11 11:04

Jagadesh


People also ask

Can a browser read your clipboard?

Sites should never have access to the content of the clipboard, at least not without user permission. Chrome and other Chromium-based browsers have no such restriction currently. The makers of the Brave web browser considered adding the user gesture requirement in 2021, but this has not been implemented in the browser.

How can I retrieve data from clipboard?

To get to your clipboard history at any time, press Windows logo key + V. From the clipboard history, you can paste and pin frequently used items by choosing an individual item from your clipboard menu. Pinning an item keeps it from being removed from the clipboard history to make room for new items.

How do I find clipboard data in Chrome?

This hidden feature is available as a flag. To find it, open a new tab, paste chrome://flags into Chrome's Omnibox and then press the Enter key. Search for “Clipboard” in the search box.

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).


1 Answers

You'll only be able to do this in most browsers when the user explicitly triggers a paste (for example, by using Ctrl-V or the edit or context menus).

In Firefox and Opera you'll need to use a hack, such as the one I outlined here: JavaScript get clipboard data on paste event (Cross browser).

In Internet Explorer, Safari and Chrome, you can access the clipboard directly during a paste using window.clipboardData in IE and the paste event's clipboardData property in WebKit. More information can be found on the Apple developer site.

like image 50
Tim Down Avatar answered Nov 08 '22 03:11

Tim Down