jquery copy and paste button

Asked

Viewed 1,409 times

1

I would like to 'create' the copy command and paste command with jQuery.

I have a form and need to put a paste button on it to make it easy for the user

The user clicks to copy the youtube embed URL and in my form would have a "paste in input" button to facilitate

I searched but found nothing about it. I found copy but paste buttons not.

Example of what I need:

$(".pasy").click(function(){

    var copy = document.execCommand('paste');
    $("#inputyou").val(copy); 

  });    

Where by clicking the . Pasy button, the input gets "false" and not the clipboard text.

  • 1

    This library is quite famous in the community: https://github.com/zenorocha/clipboard.js/

  • Do you want that paste button to simulate Ctrl+V typed? That’s it?

  • http://stackoverflow.com/questions/22581345/click-button-copy-to-clipboard-using-jquery

  • @andrepaulo that’s right, I want the boot that does the function Ctrl + v

  • @Murillogoulart this library does the copy function, I also need the paste function

1 answer

1


window.clipboardData.getData('Text') will work in some browsers, but many in that works will open a prompt wondering if the browser can access the content of clipboard.

The answer is too probably not... it’s impossible.

Instead of having a button to paste, you could see as paste works in different types of browsers, and show users who are not familiar with using the obscure command of paste native how to use this command, with instructions directed to browser type that he’s using.

[edited]

I have been searching and found that there is no "global" function, the copy function is free because the user is sending data to the transfer area via jquery or javascript, good but the paste function, the browser would "take data from the transfer area" and with jquery javascript, as soon as the user loads up the page, the browser could pick up anything in the transfer area like photos, videos, text, data etc.. so many browsers block this activity at the end and better leaves the "paste" button aside for less problems

Browser other questions tagged

You are not signed in. Login or sign up in order to post.