Clipboard not defined
See original GitHub issueThis is my code, nothing else:
<script src="https://cdn.jsdelivr.net/clipboard.js/1.5.12/clipboard.min.js"></script>
<script>
new Clipboard('.cbcopy');
</script>
Result: Uncaught ReferenceError: Clipboard is not defined
EDIT: Meanwhile I found the hidden complete example: https://github.com/zenorocha/clipboard.js/blob/master/demo/constructor-selector.html#L18 Result is the same: Clipboard is not defined
EDIT 2: Now I found that the error only occurs when the code is loaded via AJAX. If called directly, it works. So maybe it’s no bug at all and just a matter of correct code placement. Sorry if it’s just my fault.
Issue Analytics
- State:
- Created 7 years ago
- Comments:17 (3 by maintainers)
Top Results From Across the Web
navigator.clipboard is undefined - google chrome
A minimal solution for copying tooltips when HTTPS is not yet available and the solution with document.execCommand('copy') ...
Read more >Unblocking clipboard access - web.dev
The Async Clipboard API addresses these issues, providing a well-defined permissions model that doesn't block the page. The Async Clipboard ...
Read more >Navigator.clipboard - Web APIs - MDN Web Docs
The Clipboard API adds to the Navigator interface the read-only clipboard property, which returns the Clipboard object used to read and ...
Read more >ClipboardItem is not defined : r/learnjavascript - Reddit
Hi, I'm trying to copy a image generated via html2canvas to clipboard. The image generates fine, When I try to copy it to...
Read more >Clipboard (Copy & Paste) - What Web Can Do Today
The older API did not address privacy concerns properly and thus pasting is no ... execCommand('cut/copy/paste'): Programatically invokes the specified ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Same for me. Can only run using the CDN and not from node_modules folder.
Howdy folks. My app was working in development but not in production. My solution was to link
<script src="https://cdn.jsdelivr.net/npm/clipboard@1/dist/clipboard.min.js"></script>instead of linking to my local folders copy in node_modules/dist etc. Seemed to do the trick.😌Good luck!