views:

223

answers:

1

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 http://stackoverflow.com/questions/2044616/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?

+1  A: 

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.

rosscj2533

related questions