JavaScript Click Copy Copy plugin zero clipboard introduction

Source: Internet
Author: User

Writing a blog is a week at work to meet what problems, one of the benefits is to be able to make a summary, another advantage is the next encounter the same problem even if you do not remember, you can also look through your blog to solve. You can also help someone else meet the same problem as you. Or someone else has a better solution than you can discuss and analyze a better solution. So it's a good habit. Since it is a good habit, you must stick to it.

But to write a blog is not so easy, because you have to have a problem, otherwise you write, hand on the keyboard do not know what to knock. Or you take the initiative to learn, the study of your summary. Then you have to write.

This week the company colleagues to share the "Bayesian method" on my feelings are very big. Seems to have broadened my horizons. It involves statistics, psychology and many other disciplines, and then I summed up their own, learning things seem to have learned is the fur. Didn't go into it. Bayesian algorithm has not fully cleared up, read some information on the Internet, can only say a little understand. Of course such a good thing suddenly did not understand, then I will spend a little more time Bai. But before I fully understand it, let me write a blog about Bayesian methods. I think it's a certain difficulty for me. I tried to understand, but also took PPT to my girlfriend probably said again, to facilitate their own memory enhancement. She seems to know it. She always thinks she has a higher IQ than me. Well, it's a long way off.

This week is still a question to write about at work.

The questions are as follows:

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

Found a lot of methods on the Internet. Discover that although the functionality is achievable, browser compatibility is not possible.

Then think of to find JS Plug-ins, found a browser are compatible with a good JS replication plug-in Zero Clipboard.

The realization principle of Zero Clipboard

Zero Clipboard uses Flash for replication, preceded by a Clipboard copy solution, which utilizes a hidden flash. But the latest Flash Player 10 only allows operations on flash to start the Clipboard. So Zero Clipboard has improved on this, using a transparent flash, let it float on the button, so in fact, click not the button but flash, you can use flash copy function.

How to use Zero Clipboard

First download Zero Clipboard and unzip it. Two files are required: Zeroclipboard.js and zeroclipboard.swf, put these two files into your project.

There is a small example when downloading. As follows:

<! DOCTYPE html>  

The effect of the following figure:

Then you can paste it in the place where you need it.

And then use the function in the actual project,

The effect of the following figure:

The code is as follows:

The TD tag in the content to be copied in TR adds:

Note: $i is the circular data. Cycle once, $i + +;

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

The styles are 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 ("Copy succeeded, copy content as:" + args.text);  
    <?php endfor;?>  
</script>

Finally, just OK, testing a few browser features are OK.

Author: csdn Blog Wind Fire Programmer

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.