无论浏览器如何复制textarea文本 [英] copying textarea text regardless of browser
问题描述
所以我想我的问题有两个方面,这是可能的,如果是这样,是否可以这样做,使浏览器使用不是一个因素? p>
感谢您对此问题的帮助和回应。
可能,但在浏览器中并不一致。您可以使用jQuery插件剪贴板作为替代品。
这个插件在内部使用Flash对象来复制到剪贴板,这应该在浏览器中保持一致。
包含插件后,下面的代码应该可以工作:
var text = $(textarea)。text();
$ .clipboard(text);
这会将文本区域中的所有内容复制到剪贴板。
I"m trying to do something that I originally thought would be quite simple, but it's turning out not to be. Mainly I'm trying to have so I can have a textarea on a page, with a button that would allow the user to copy everything within the textarea to paste wherever they wish. However after slogging through a few attempts and a lot of applications of google-fu, I've yet to have an example that works, much less is cross browser compatible.
So I guess my question is two fold; is this possible, and if so, is this able to be done so that the browser used isn't a factor?
Thanks for your help and responses to this question.
This is possible, but isn't consistent across browsers. You can use the jQuery plugin Clipboard as a substitute.
This plugin uses a Flash object internally to copy to the clipboard, which should be consistent across browsers.
With the plugin included, the following code should work:
var text = $("textarea").text();
$.clipboard(text);
That will copy everything in the text area to the clipboard.
这篇关于无论浏览器如何复制textarea文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!