From: CMDR furrycat Date: Fri, 17 Jun 2016 13:05:23 +0000 (-0400) Subject: Copy table without escaping HTML. X-Git-Url: http://git.furryclan.net/?a=commitdiff_plain;h=d70ba71ac83408043e7c9539f3bc7a1d7db90f5e;p=furrycat%2Frace-o-matic.git Copy table without escaping HTML. --- diff --git a/common.js b/common.js index 2db1bad..26dd094 100644 --- a/common.js +++ b/common.js @@ -11,9 +11,14 @@ function copy_clipboard(event) { area.style.width = '2em'; area.style.padding = 0; area.style.background = 'transparent'; + area.setAttribute('readonly', ''); area.value = text; document.body.appendChild(area); - area.select(); + var range = document.createRange(); + range.selectNode(area); + var selection = window.getSelection(); + selection.removeAllRanges(); + selection.addRange(range); if (document.execCommand('copy')) console.log('Copied bbcode to clipboard.'); else console.log('Failed to copy bbcode to clipboard.'); document.body.removeChild(area);