[英]Pasting text from clipboard to Firefox and Chrome
I am using this function that pastes text from clipboard into multiple text fields. 我正在使用此功能,可将剪贴板中的文本粘贴到多个文本字段中。
function pasteFromClipboard(className) {
var data = window.clipboardData.getData('Text');
if (data != null) {
var cells = data.split('\n');
var columns = $$('.'+className);
for (i = 0; i < cells.length; i++) {
if ( columns[i] != undefined ){
columns[i].value = cells[i];
}
}
}
}
This stuff that is attached to button via "onClick" works in IE, but not in FF or Chrome. 通过“ onClick”附加到按钮上的东西在IE中有效,但在FF或Chrome中不起作用。 Now I know FF restricts access to clip, but I have manipulated the values in preferences with no success.
现在,我知道FF限制了对短片的访问,但是我在首选项中操纵值没有成功。
Can anyone help me out with this functionality, so it would work in Chrome? 谁能帮我这个功能,以便它可以在Chrome中使用? Is there a
window.clipboardData.getData('Text');
是否有一个
window.clipboardData.getData('Text');
similar option to make it work in FF and Chrome? 使其在FF和Chrome中工作的类似选项?
OK. 好。 So I gave up on this some time ago.
所以前段时间我放弃了。 I just created an additional
textarea
control, where I paste my stuff into. 我刚刚创建了一个附加的
textarea
控件,将其粘贴到其中。
Actions on page then read this control and do the work - then delete the content in this control. 页面上的操作,然后阅读此控件并进行工作-然后删除此控件中的内容。
Some would say its a clumsy solution, but i prefer "old fashion" and safe. 有人会说这是一个笨拙的解决方案,但我更喜欢“老式”且安全。
Best regards, no9. 最好的问候,没有。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.