[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 842
  • Last Modified:

Copy grid row content to clipboard using javascript


I like to copy a selected row from a GridView to the clipboard using JavScript.
What I need is a function that the user can copy the selected row and if he paste it a new row will append with the date that had been copied before.
Copy to other targets would be fine but is not the most important think.

As I've never worked with the clipboard before I've no idea how to do something like this.
How can I do it as a Cross-Browser solution?


  • 3
  • 2
1 Solution
JavaScript alone isn't permitted to access the clipboard in most browsers, due to security reasons, except Internet Explorer.

I've found a good tutorial for mixing a simple Flash and JavaScript to achieve cross-browser copy-to-clipboard ability. This tutorial also shows you how to use plain JavaScript in Internet Explorer:


Try to follow the tutorial, and come back if you couldn't understand it...
Actually, forget about that previous link, here's a working solution:

Please provide the key code that you're using or a link to your web page if you want a customized solution!
andre72Author Commented:
Thanks I would agree with this solution but tha matter is that I really don't like to have a flash button for it ...
An embedded hidden flash control where I can add text using JavaScript or like that would be ok.
Is this also possible with this movie?
I'm sorry, I'd never used flash before ...
andre72Author Commented:
Thanks for your support - works at all
"I really don't like to have a flash button for it"
- From what I've learned so far, you're kind of stuck with it for now... until something better is available for use in the near future.

"An embedded hidden flash control where I can add text using JavaScript or like that would be ok.
Is this also possible with this movie?"
- To be honest, I don't have a sufficient knowledge with flash--yet--but, as far as I know, you're kind of forced to use an invisible, positioned flash button, that will be placed on top of a real HTML button, such as that in the previous link. This is so because, as the linked page has mentioned, Flash 10+ requires that the user, at the very least, clicks the Flash "movie" to prove that it is the user that has initialized and authorized actions performed by the Flash "movie," not some random script of yours. This is done by Flash, in general, for protecting the user's privacy and enhancing the user's security. Consequently, you can "add text using JavaScript," but you won't be able to copy it into the user's clipboard, unless you're using an "authorized" Flash.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now