Every line of 'copy to clipboard jquery' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
202 function copyToClipboard(element) { 203 $(element).select() 204 document.execCommand("copy"); 205 }
4 function copyToClipboard(text) { 5 const onCopy = ev => { 6 ev.clipboardData.setData("text/plain", text) 7 ev.preventDefault() 8 } 9 10 document.addEventListener("copy", onCopy, { once: true }) 11 document.execCommand("Copy", false, null) 12 }
159 function copyToClipboard(text) { 160 document.addEventListener( 161 "copy", 162 function(e) { 163 e.clipboardData.setData("text/plain", text); 164 e.preventDefault(); 165 }, 166 { once: true } 167 ); 168 document.execCommand("copy"); 169 }
154 function copyToClipboard(str, mimetype) { 155 // Listen for 'oncopy' event 156 document.oncopy = function (event) { 157 event.clipboardData.setData(mimetype, str); 158 event.preventDefault(); 159 }; 160 161 // Execute browser command 'Copy' 162 document.execCommand("Copy", false, null); 163 }
7 function copy_to_clipboard(value) { 8 const el = document.createElement('textarea'); 9 el.value = value; 10 el.setAttribute('readonly', ''); 11 el.style.position = 'absolute'; 12 el.style.left = '-9999px'; 13 document.body.appendChild(el); 14 const selected = document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false; 15 el.select(); 16 document.execCommand('copy'); 17 document.body.removeChild(el); 18 if (selected) { 19 document.getSelection().removeAllRanges(); 20 document.getSelection().addRange(selected); 21 } 22 }
12 export function copyToTheClipboard(string: string) { 13 const doCopy = function(e: any) { 14 e.clipboardData.setData("text/plain", string); 15 e.preventDefault(); 16 }; 17 18 document.addEventListener("copy", doCopy); 19 document.execCommand("copy", false, null); 20 document.removeEventListener("copy", doCopy); 21 }
107 function copyToClipboard(text) { 108 if (window.clipboardData && window.clipboardData.setData) { 109 /*IE specific code path to prevent textarea being shown while dialog is visible.*/ 110 return clipboardData.setData("Text", text); 111 112 } else if (document.queryCommandSupported && document.queryCommandSupported("copy")) { 113 var textarea = document.createElement("textarea"); 114 115 textarea.textContent = text; 116 textarea.style.position = "fixed"; /* Prevent scrolling to bottom of page in MS Edge.*/ 117 document.body.appendChild(textarea); 118 textarea.select(); 119 120 try { 121 return document.execCommand("copy"); /* Security exception may be thrown by some browsers.*/ 122 } catch (ex) { 123 console.warn("Copy to clipboard failed.", ex); 124 return false; 125 } finally { 126 document.body.removeChild(textarea); 127 } 128 } 129 }
231 function copyToClipboard(text) { 232 if (window.clipboardData && window.clipboardData.setData) { 233 // IE specific code path to prevent textarea being shown while dialog is visible. 234 return clipboardData.setData("Text", text); 235 236 } else if (document.queryCommandSupported && document.queryCommandSupported("copy")) { 237 var textarea = document.createElement("textarea"); 238 textarea.textContent = text; 239 textarea.style.position = "fixed"; // Prevent scrolling to bottom of page in MS Edge. 240 document.body.appendChild(textarea); 241 textarea.select(); 242 try { 243 return document.execCommand("copy"); // Security exception may be thrown by some browsers. 244 } catch (ex) { 245 console.warn("Copy to clipboard failed.", ex); 246 return false; 247 } finally { 248 document.body.removeChild(textarea); 249 } 250 } 251 } return {
219 function copyToClipboard(text) { 220 SHARED.buffer.value = text; 221 SHARED.buffer.select(); 222 document.execCommand('copy'); 223 }
15 copyToClipboard() { 16 const range = document.createRange(); 17 range.selectNodeContents(this._code); 18 const selection = window.getSelection(); 19 selection.removeAllRanges(); 20 selection.addRange(range); 21 document.execCommand('copy'); 22 }