0

Do anyone know how I can copy information via href to clipboard? I'm going for something like this;

<?php

print "Number: <a href=\"" . $number . ">" . $number . "</a>";

?>

When something click the link the information given in $number should be copied.

Thanks!

  • http://stackoverflow.com/questions/400212/how-to-copy-to-the-clipboard-in-javascript – Mina Oct 11 '13 at 10:07

5 Answers5

0

The solution I use is ZeroClipboard.

Nick
  • 5,767
  • 10
  • 50
  • 77
0

There are a few options, I'd go down the jQuery route if I wanted to do the same. There's some info here which might help: http://www.jquery4u.com/plugins/jquery-copy-clipboard-4-options/

H2ONOCK
  • 938
  • 1
  • 5
  • 17
0

PHP is server-side, and clipboard is client-side. Copying is not embedded in HTML, but you can use libraries like jQuery ZeroClipboard.

d.sergeiev
  • 303
  • 2
  • 8
0

This is not possible with PHP and is possible with JavaScript and jQuery.

You may display the text into a selector having some specific class or ID.

Then you may use jQuery + zClip. zClip is a lightweight jQuery "copy to clipboard" plugin built using the popular Zero Clipboard library. This plugin uses an invisible Adobe Flash movie that is fully compatible with Flash Player 10 and below.

Here is the link http://www.steamdev.com/zclip/

Alfred
  • 19,306
  • 58
  • 155
  • 232
0

putting things in the clipboard is a "hack". A security breach that is patched more and more.

Via PHP this can not be done since PHP is a server-side technology. You can do it in Javascript but recent browsers does not allow access to clipboard. Of course Adobe Flash is still vulnerable to this so you can try using that tech.

ZeroClipboard is the most known plugin to do this

Bibear
  • 69
  • 8