coure2011
coure2011

Reputation: 42454

How to detect whether clipboard.js is supported or not

Using clipboard plugin http://zenorocha.github.io/clipboard.js/ Can I know programmatically whether this plugin is supported or not on the running browser? The idea is I want to hide the 'copy to clipboard' button if the plugin is not supported. Something like

if(clipboard is not supported) {
    $('.copy-btn').hide();
}

Upvotes: 1

Views: 1081

Answers (3)

Zeno Rocha
Zeno Rocha

Reputation: 3586

You can use document.queryCommandSupported but there are some known bugs. That's why I recommend using this polyfill.

Upvotes: 1

Harikrishnan
Harikrishnan

Reputation: 3802

You have to check whether the browser version is greater than or equal to those mentioned in the "Browser Support" section.

https://github.com/zenorocha/clipboard.js#browser-support

Upvotes: 0

Paul S.
Paul S.

Reputation: 66334

You can document.queryCommandSupported the required underlying command

if (!(document.queryCommandSupported && document.queryCommandSupported('copy'))) {
    $('.copy-btn').hide();
}

Upvotes: 2

Related Questions