ZeroClipboard (link clicked) not working as expected

I am using zeroclipboard for copy function but it doesn't seem to work as expected.

I am trying to copy data from a page by clicking a link.

I have included the required 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 following function in 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);
}

      

The copy function works fine when I double click on the link, but doesn't work if I click on the copy link. Also for some reason, the data that was copied initially is not 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 problem?

+3


source to share





All Articles