function Copy() // this function will be latched to a button later on.
{
var text = writePreview(); // this pours in the formatted string by the writePreview() function to the variable 'text'
text = br2nl(text); //variable 'text' is purified from <br/> and is replaced by a carriage return
//I need some code here to pour in the contents of the variable 'text' to the clipboard. That way the user could paste the processed data to a 3rd party application
}
我正在构建一个离线的客户端Web应用程序。这样做的主要目的是让用户输入字段,格式化文本使其符合特定条件,然后单击复制,以便将其粘贴到第三方CRM。如何使用JavaScript将变量的内容放入剪贴板?
唯一可用的浏览器是Google Chrome。我搜索了互联网,希望找到一个简单的解决方案。
我不关心安全性,因为这个应用程序不会被发布,只是为了脱机使用。
我想保持它尽可能简单,并添加不可见的textarea破坏布局。我目前的环境中不允许使用Flash。
可能重复[如何在JavaScript中复制到剪贴板?](http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript) –