Link to home
Start Free TrialLog in
Avatar of andre72
andre72

asked on

Copy grid row content to clipboard using javascript

Hi,

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?

Thanks

Andre
Avatar of hsq91
hsq91
Flag of United States of America image

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:

http://www.jeffothy.com/weblog/clipboard-copy/

Try to follow the tutorial, and come back if you couldn't understand it...
ASKER CERTIFIED SOLUTION
Avatar of hsq91
hsq91
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andre72
andre72

ASKER

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 ...
Avatar of andre72

ASKER

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.