diff options
Diffstat (limited to 'client/simple/src/js/main/results.ts')
| -rw-r--r-- | client/simple/src/js/main/results.ts | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/client/simple/src/js/main/results.ts b/client/simple/src/js/main/results.ts index 8b2d8c9b6..42298f9f8 100644 --- a/client/simple/src/js/main/results.ts +++ b/client/simple/src/js/main/results.ts @@ -121,7 +121,19 @@ listen("click", "#copy_url", async function (this: HTMLElement) { const target = this.parentElement?.querySelector<HTMLPreElement>("pre"); assertElement(target); - await navigator.clipboard.writeText(target.innerText); + if (window.isSecureContext) { + await navigator.clipboard.writeText(target.innerText); + } else { + const selection = window.getSelection(); + if (selection) { + const range = document.createRange(); + range.selectNodeContents(target); + selection.removeAllRanges(); + selection.addRange(range); + document.execCommand("copy"); + } + } + const copiedText = this.dataset.copiedText; if (copiedText) { this.innerText = copiedText; |