ZeroClipboard issue

65 views Asked by At

I am trying to copy the link of current page using ZeroClipboard and I don't know what to do further. This is my code until now. How can I copy the link?

function copyLink() {
  document.getElementById("copy").value += window.location.href;
  var link = document.getElementById("copy").value;
  var client = new ZeroClipboard();
  client.setText(link);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.2.0/ZeroClipboard.Core.min.js"></script>
<html>

<head>
  <title>Copy</title>
</head>

<body>
  <div>
    <button id="copyBtn" onclick="copyLink()">Copy link</button>
    <textarea id="copy" style="display: none;"></textarea>
  </div>
</body>

</html>

Thanks !

0

There are 0 answers