I have a htlm table with lots of data the user might want to copy to paste into Excel or whatever...
Since it's big I want to help user selecting it, he can then copy & paste himself.
I found this Select a complete table with Javascript (to be copied to clipboard)
but it creates a security error (code 1000) in FF, any thoughts? Can this be done more efficiently with jQuery?
I've never used it, but there is a jQuery clipboard plugin that could suit your needs. It sounds like it would copy something to the clipboard, but should work cross-browser. The code would be something like
$.clipboard($('#tableContainer').html());
Edit: I just noticed that this solution would require non-IE browsers to have Flash installed, which is inconvenient as best and makes it unusable at worst. The only way I could think to do this without having the browser access the clip board would be to display a hidden textarea control with the results of this call:
$('#tableContainer').html()
and then allow the user to select all the text and copy it. It would work, but not be as elegant as the plugin solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With