问题
This question already has an answer here:
- How do I copy to the clipboard in JavaScript? 55 answers
The workflow is simple:
- You click inside a textarea.
- The text is copied to the client\'s clipboard.
- Display notice to the user.
How do you do it?
回答1:
Copying to the clipboard is a tricky task to do in Javascript in terms of browser compatibility. The best way to do it is using a small flash. It will work on every browser. You can check it in this article.
Here's how to do it for Internet Explorer:
function copy (str)
{
//for IE ONLY!
window.clipboardData.setData('Text',str);
}
来源:https://stackoverflow.com/questions/1539641/how-to-copy-text-to-the-clients-clipboard-using-jquery