mirror of https://github.com/portainer/portainer
parent
4aea5690a8
commit
7cc28b10a0
|
@ -32,7 +32,19 @@ export function CopyButton({
|
||||||
function onClick() {
|
function onClick() {
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Clipboard
|
// https://developer.mozilla.org/en-US/docs/Web/API/Clipboard
|
||||||
// https://caniuse.com/?search=clipboard
|
// https://caniuse.com/?search=clipboard
|
||||||
navigator.clipboard.writeText(copyText);
|
if (navigator.clipboard) {
|
||||||
|
navigator.clipboard.writeText(copyText);
|
||||||
|
} else {
|
||||||
|
// https://stackoverflow.com/a/57192718
|
||||||
|
const inputEl = document.createElement('input');
|
||||||
|
inputEl.value = copyText;
|
||||||
|
inputEl.type = 'text';
|
||||||
|
document.body.appendChild(inputEl);
|
||||||
|
inputEl.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
inputEl.type = 'hidden';
|
||||||
|
document.body.removeChild(inputEl);
|
||||||
|
}
|
||||||
setIsFading(true);
|
setIsFading(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue