diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/share/js/wm.js | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/web/share/js/wm.js b/web/share/js/wm.js index 633ac463..e6a7c46d 100644 --- a/web/share/js/wm.js +++ b/web/share/js/wm.js @@ -145,9 +145,7 @@ function __WindowManager() { /************************************************************************/ self.copyTextToClipboard = function(text) { - navigator.clipboard.writeText(text).then(function() { - wm.info("The text has been copied to the clipboard"); - }, function(err) { + let workaround = function(err) { // https://stackoverflow.com/questions/60317969/document-execcommandcopy-not-working-even-though-the-dom-element-is-created let callback = function() { tools.error("copyTextToClipboard(): navigator.clipboard.writeText() is not working:", err); @@ -179,7 +177,16 @@ function __WindowManager() { } }; __modalDialog("Info", "Press OK to copy the text to the clipboard", true, false, callback); - }); + }; + if (navigator.clipboard) { + navigator.clipboard.writeText(text).then(function() { + wm.info("The text has been copied to the clipboard"); + }, function(err) { + workaround(err); + }); + } else { + workaround("navigator.clipboard is not available"); + } }; self.info = (...args) => __modalDialog("Info", args.join(" "), true, false); |