Does document.execCommand ('copy') have a size limit?

I am using document.execCommand ('copy') similar to what is described here:

https://developers.google.com/web/updates/2015/04/cut-and-copy-commands

In my case, I am placing data from the Kendo grid in a hidden text area for copying. Somewhere between 2500 and 3000 lines, or about 350k. Data copy doesn't work.

I hid the textbox to make sure it gets the full content of the grid and it works. I can copy all 3000+ lines manually from the visible textbox.

But document.execCommand cannot copy it. Is there a size limit that I am reaching?

+3


source to share


1 answer


When you say "unable to copy" I am assuming you are not getting the error, but it just doesn't add anything to the clipboard.

Try expanding the textbox and see if your code works.



I ran into something similar with hidden texarea. I ended up doing something like this.

$('#txtCopy').show();
var copyData = document.querySelector('#txtCopy'); 

window.getSelection().removeAllRanges(); 
var range = document.createRange();
range.selectNodeContents(copyData);
window.getSelection().addRange(range);

var successful = document.execCommand('copy');

console.log(successful);
$('#txtCopy').hide();

      

+1


source







All Articles