Select entire table / text to copy to clipboard

I have an htlm table with a lot of data that the user can copy to paste into Excel or something else ...

Since it is large, I want to help the user select it, he can then copy and paste himself.

I found this. Select the full table with Javascript (for copying to the clipboard)

but it creates a security error (code 1000) in FF, any thoughts? Can this be done more efficiently with jQuery?

+5
source share
1 answer

I have never used it, but there is a jQuery clipboard plugin that can satisfy your needs. It looks like he copied something to the clipboard, but the cross browser should work. The code will be something like

$.clipboard($('#tableContainer').html()); 

Edit: I just noticed that this solution would require non-IE browsers to install Flash, which is as inconvenient as possible and makes it unusable in the worst case. The only way I could think of doing this without having access to the clip browser would be to display the hidden textarea control with the results of this call:

$('#tableContainer').html()

and then allow the user to select all the text and copy it. This will work, but not as elegantly as the plugin solution.

+3
source

All Articles