JS click to Copy the plug-in -- Zero Clipboard

Source: Internet
Author: User

Blog writing is what problems you encounter during a week's work. One advantage is that you can make a summary. The other advantage is that you will encounter the same problem next time, even if you cannot remember it, you can also read your blog to solve the problem. It can also help people who encounter the same problems as you. Or if someone else has a better solution than you, you can discuss and analyze it together to find a better solution. So this is a good habit. Since it is a good habit, you must stick to it.


However, it seems that it is not so easy to write a blog, because you have to have a problem, or you don't know what to write or put your hands on the keyboard. Or you can take the initiative to learn and summarize your learning. Then you have to write.

This week, my colleagues in the company shared a lot of feelings about the Bayesian method. It seems that my knowledge has been broadened. The statistics, psychology, and so on are involved in many disciplines. Then I sum up myself, and what I learned seems to be what I learned. Not in-depth. The Bayesian algorithm has not been fully clarified. I have read some information on the Internet and can only explain it. Of course I don't understand such a good thing at once, so I will spend more time. But before I fully understand it, it is difficult for me to write a blog about Bayesian methods. I tried to understand it. I also gave my girlfriend a PPT to talk about it, so that I could improve my memory. She seems to understand. She always thinks she has a higher IQ than me. Okay, it's far away.


This week I will write a question about my work.

The problem is as follows:

There are many columns in the table, and I have to copy the URLs of each column. Click Copy to copy the URL of the current column;

I found many methods online. It is found that although the function can be implemented, the browser compatibility is not good.

Then I tried to find the js plug-in and found a JS replication plug-in Zero Clipboard that is compatible with various browsers.

Zero Clipboard implementation principle Zero Clipboard uses Flash for copying. Previously there was a Clipboard Copy solution, which used a hidden Flash. However, the latest Flash Player 10 allows you to start the clipboard only by performing operations on the Flash. Therefore, Zero Clipboard has been improved, and a transparent Flash is used to float the button. In this way, the Flash copy function can be used instead of the button but Flash.

How to use Zero ClipboardDownload the Zero Clipboard and decompress it. Two files are required: ZeroClipboard. js and ZeroClipboard.swf. Put these two files into your project.

The download contains a small example. As follows:

<! DOCTYPE html> 

The effect is as follows:


Then press CTRL + V to paste the file.

Then, the function is used in the actual project,

The effect is as follows:


The Code is as follows:

Add:

Note: $ I is generated from cyclic data. Loop once, $ I ++;

 <td id='fe_text<?php echo $i; ?>'>

The style is introduced as follows:

<Script type = "text/javascript" src = "/misc/js/ZeroClipboard. js"> </script> <script type = "text/javascript"> <? Php for ($ r = 0; $ r <$ I; $ r ++):?> Var clip = new ZeroClipboard (document. getElementById ("d_clip_button <? Php echo ($ r + 1);?> "), {MoviePath:"/misc/js/ZeroClipboard.swf "}); clip. on ('complete', function (client, args) {alert ("Copied successfully, copied content:" + args. text) ;}); <? Php endfor;?> </Script>


Finally, it's okay. I tested several browser functions that are OK.




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.