3

I am using zeroclipboard for copy functionality but it doesnt seem to work properly..

I am trying to copy the data from the page on click of a link.

I have included the necessary files in my html,

<script type="text/javascript" src="/DataTables-1.9.4/zeroclipboard/ZeroClipboard.js"></script>
<script language="JavaScript">
    ZeroClipboard.setMoviePath('/DataTables-1.9.4/zeroclipboard/ZeroClipboard.swf');    
</script>

I have the below function in my js file

<a href='javascript:void(0);' onclick=copy(\""+idValue+"\") id=d_clip_button><font size=2 color=blue>Copy to clipboard</a>

function copy(elementIdValue){

var value=$("#"+elementIdValue).html();
var clip = new ZeroClipboard.Client();
var myTextToCopy = $(value).text();  

clip.glue('d_clip_button');
clip.addEventListener('onMouseover', clipboardEvent);
function clipboardEvent() {
            clip.setText( finalText);
}

Copy functionality works fine when I double click the link but doesn't work if I single click the copy link. Also for some reason the data copied initially doesn't get deleted.. When I open a new page and try to copy the data, it still has the old data. Can someone please let me know how to fix this issue?

Learner
  • 2,303
  • 9
  • 46
  • 81

0 Answers0