Answer the question
In order to leave comments, you need to log in
How to paste text from clipboard in JavaScript?
You need to get to the contents of the buffer (text) and paste it into a variable in JS. If everything is clear with IE, then what about other browsers?
The bottom line is that the main application is written in GWT and the key combination is processed first. So despite the fact that the document already hangs eventListener
on 'paste' - it is the browser paste that does not work. From GWT comes only KeyboardEvent
. I can create and call a paste event like
var pasteEvent = $doc.createEvent ("Event");
pasteEvent.initEvent ('paste', true, false);
$doc.dispatchEvent (pasteEvent);
$doc.addEventListener('paste', function(e) {
var clipboardData = e.clipboardData;
console.log('Clipboard Plain Text: ' +
clipboardData.getData('text/plain')); });
Answer the question
In order to leave comments, you need to log in
You cannot do this using js - this is an unsafe action, you may have passwords in the buffer, no one should read them on the sly.
In general, everything has been written for a long time. Do you have problems with Google? stackoverflow.com/questions/400212/how-do-i-copy-t...
The question is closed. The reason turned out to be keyDownEvent.preventDefault();
in the key combination handler from the GWT side.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question