Copy text from DIV by clicking button
How to make "Copy button", that will copy all texts from :
<div id="x">
<span id="text">text开发者_运维技巧</span>
<span id="info">text</span>
....
</div>
to clipboard
The only way i believe this is possible, is by communicating with Flash via JavaScript. You're not able to access these things with just JavaScript for security reasons.
http://code.google.com/p/zeroclipboard/
You may want to take a loop at this jQuery plugin:
http://plugins.jquery.com/project/clipboard
There doesn't seem to be a native way to do this and all of the code samples I've looked at, including the plugin above, all seem a bit sketchy.
In IE it's possible to use some IE native code to do the copy but for other browsers there's a reliance on Flash, which, as of version 10 seems to impliment further restrictions on this action.
精彩评论