简体   繁体   English

将剪贴板中的文本粘贴到Firefox和Chrome

[英]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.

相关问题 使用 FireFox、Safari 和 Chrome 在剪贴板上复制/放置文本 - Copy / Put text on the clipboard with FireFox, Safari and Chrome Firefox:将剪贴板中的文本粘贴到输入中 - Firefox: paste text from clipboard into input 从chrome app中获取剪贴板中的当前文本 - Get current text from clipboard in chrome app 在firefox和谷歌浏览器上复制到剪贴板 - Copy to clipboard on firefox and google chrome 使用 JavaScript onclick 从剪贴板粘贴到 textarea - Pasting from clipboard into textarea using JavaScript onclick 使用Mozilla导航器从剪贴板粘贴内容 - Pasting content from clipboard using mozilla navigator 粘贴前替换剪贴板中的特殊字符 - Replace special characters from clipboard before pasting 将文本从 Firefox WebExtension 中的后台脚本复制到剪贴板 - Copy text to clipboard from background script in a Firefox WebExtension 使用 Firefox 粘贴从 Windows 剪贴板复制的图像时,Javascript 问题、clipboardData.items 和 clipboardData.files 为空 - Javascript issue, clipboardData.items and clipboardData.files are empty when pasting an image copied from the Windows clipboard when using Firefox 如何从Google Chrome扩展程序将HTML格式的文本复制到剪贴板? - How to copy HTML formatted text on to Clipboard from Google Chrome extension?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM