I am using the Accusoft document viewer. I have a requirement for a button that when clicked will copy to the clipboard the current URL plus a page number querystring parameter. I am using clipboard.js. I know exactly how to get the current URL and how to add a page number parameter to the URL. What I don't know how to do is make clipboard.js copy a variable (such as the generated URL with page number parameter) to the clipboard. Any help on this?
Clipboard.js creator here ;)
You can use the imperative API to achieve that:
var url = document.location.href;
new Clipboard('.btn', {
text: function() {
return url;
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.5.10/clipboard.min.js"></script>
<button class="btn">Copy</button>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With