Innovate anywhere, anytime Your cloud-based dev studio.

Copy Text to ClipBoard Event using Javascript


Accessing copy to ClipBoard event using Javascript

This Blog describes, how we can copy to clipboard using JavaScript. Copying content from a web form without needing to use the default browser functions. For this i am using ZeroClipboard functionality in the JavaScript.

Following are the steps to develop this code.

  1. Create a new web application.
  2. Include ZeroClipboard.js file in to your web application location or you can use online link mentioned below

<script src=""></script>

3.Here is the following code you have to add in script, HTML, and can add styles(CSS) for it.

<div class="email-modal">
<div >
  <div role="document">
        <h4>Text To Copy:</h4>
      <div class="modal-body">
         <textarea class="text_copy" rows="5" cols="100" >text to Copy</textarea>
        <button id='clip_board' data-clipboard-text="" class="copy-button">Copy to ClipBoard</button>
<script src=""></script>
<script src=""></script>
<script type="text/javascript">
$('#clip_board').attr('data-clipboard-text', $(".text_copy").text())
window.onload = function(){
    var client = new ZeroClipboard(document.getElementsByClassName("copy-button") );
    client.on( "ready", function( readyEvent ) {
      client.on( "aftercopy", function( event ) {
        alert("Copied.." );

Here "copy-button" is "button class" mentioned in the html whis reads your html markup content.