DOMException on calling navigator.clipboard.readText()

This seems to happen when executing code from the devtools console or snippets. Workaround: You can execute the code below and focus on the window within 3 seconds, by clicking somewhere, or just by pressing <tab>. e.g. from snippets Ctrl-Enter <Tab> e.g. from console Enter <Tab> setTimeout(async()=>console.log( await window.navigator.clipboard.readText()), 3000)

Copy selected text to the clipboard WITHOUT using flash – must be cross-browser

execCommand(‘copy’) There is a very new option. It is cross-browser but it will take time until everyone has updated their browser. It works by using the document.execCommand(‘copy’); function. With this function you’ll copy the select text. This will not only work with textareas but with every selected text on the webpage (like in span, p, … Read more

How can I copy rich text contents to the clipboard with JavaScript?

With modern browsers, if you want copy rich text only, there is a very easy solution without using any packages. See http://jsfiddle.net/jdhenckel/km7prgv4/3 Here is the source code from the fiddle <button onclick=”copyToClip(document.getElementById(‘foo’).innerHTML)”> Copy the stuff </button> <div id=foo style=”display:none”> This is some data that is not visible. You can write some JS to generate this … Read more

Copy to Clipboard in Chrome Extension

All credit goes to joelpt, but in case anyone else needs this to work in pure javascript without jQuery (I did), here’s an adaptation of his solution: function copyTextToClipboard(text) { //Create a textbox field where we can insert text to. var copyFrom = document.createElement(“textarea”); //Set the text content to be the text you wished to … Read more

Using execCommand (Javascript) to copy hidden text to clipboard

Here’s my solution that doesn’t use jQuery: function setClipboard(value) { var tempInput = document.createElement(“input”); tempInput.style = “position: absolute; left: -1000px; top: -1000px”; tempInput.value = value; document.body.appendChild(tempInput); tempInput.select(); document.execCommand(“copy”); document.body.removeChild(tempInput); } <!DOCTYPE html> <html> <head> <title>Set Clipboard</title> </head> <body> <button onclick=”setClipboard(‘foo loves bar’)”>Set Clipboard</button> </body> </html>

Clipboard size limit

Applications call GlobalAlloc(GMEM_MOVEABLE or GMEM_DDESHARE) to allocate the memory for data to be stored on the clipboard and make it available to other applications. For 32-bit applications GlobalAlloc can allocate blocks up to 2 GB in size or up to the amount of virtual memory the PC has, whichever is less. The Windows clipboard does … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)