Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
337 views
in Technique[技术] by (71.8m points)

javascript - 如何使用jQuery将文本复制到客户端的剪贴板? [重复](How to copy text to the client's clipboard using jQuery? [duplicate])

This question already has an answer here:

(这个问题已经在这里有了答案:)

The workflow is simple:

(工作流程很简单:)

  1. You click inside a textarea.

    (您在文本区域内单击。)

  2. The text is copied to the client's clipboard.

    (文本被复制到客户的剪贴板。)

  3. Display notice to the user.

    (向用户显示通知。)

How do you do it?

(你怎么做呢?)

  ask by mager translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Copying to the clipboard is a tricky task to do in Javascript in terms of browser compatibility.

(就浏览器兼容性而言,复制到剪贴板是用Javascript要做的一项棘手任务。)

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:

(这是针对Internet Explorer的操作方法:)

function copy (str)
{
    //for IE ONLY!
    window.clipboardData.setData('Text',str);
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.8k users

...