button copy and paste with jquery

1

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

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

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

I researched but did not find anything about it. I found copy buttons but not paste.

Example of what I need:

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

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

  });    

When you click the .pasy button, the input receives "false" instead of the text from the clipboard.

    
asked by anonymous 02.03.2017 / 20:06

1 answer

1

window.clipboardData.getData('Text') will work in some browsers, but many it works will open prompt asking if the browser can access content from clipboard .

The answer is very likely that it will not be impossible.

Instead of having a paste button, you could see how% works in different types of browsers , and show users who are not familiar with using the obscure command from paste native how to use this command, with instructions directed to the type of browser it is using. >

[edited]

I've been researching and found that there is no "global" function, copy and free function because the user is sending data to the transfer area via jquery or javascript, but the paste function, the browser "would get data from the area and jquery the javascript, as soon as the user loads the page, the browser could pick up anything in the transfer area, such as photos, videos, text, data etc ... so many browsers block this activity, in the end and better leave the "paste" button aside for less trouble

    
03.03.2017 / 13:21