Copy to clipboard using javascript(Zeroclipboard)

I tried so many ways to implement this, but found the below snippet very useful(using zeroclipboard.js)

<script type=”text/javascript” src=”ZeroClipboard.js”></script>
<script type=”text/javascript”>
//set path
//create client
var clip = new ZeroClipboard.Client();

clip.setHandCursor( true );

clip.addEventListener(‘mousedown’, function () {
clip.addEventListener(‘complete’, function (client, text) {
alert(‘copied: ‘ + text);
//glue it to the button

<textarea name=”box-content” id=”box-content” rows=”5″ cols=”70″>
Amit Mohanty Blog is the best blog around! 
<br />
<br />
<input type=”button” id=”copy” name=”copy” value=”Copy to Clipboard” />

Make sure to include both files Zeroclipboard.js and ZeroClipboard.swf

That’s it.


13 thoughts on “Copy to clipboard using javascript(Zeroclipboard)

  1. I truly love your website.. Pleasant colors & theme.
    Did you develop this amazing site yourself? Please
    reply back as I’m hoping to create my very own website and want to find out
    where you got this from or what the theme is called.

    Many thanks!


  2. I have been explooring for a little bit forr any high-quality
    articles or weblog posts on this sort of house .
    Exploring in Yahoo I at laast stumbled upon this website. Reading this info So i’m happy to exhibit
    that I have a very just right uncanny feeling I found out exactly what
    I needed. I such a lot indisputably will make sure
    to do not disregard this site and give it a look regularly.


  3. Hello superb website! Does running a blog similar to this require a lot of work?

    I have absolutely no expertise in computer programming
    but I had been hoping to start my own blog in the near future.
    Anyhow, if you have any suggestions or techniques for new blog owners please share.
    I know this is off topic however I just wanted
    to ask. Many thanks!


  4. Have you ever thought about adding a little bit more than just your articles?

    I mean, what you say is valuable and all. But think
    of if you added some great images or video clips to give your posts
    more, “pop”! Your content is excellent but with pics and video clips, this
    site could definitely be one of the most beneficial in its field.
    Awesome blog!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s