Introduction
Introduction Statistics Contact Development Disclaimer Help
clipcopy.js - jscancer - Javascript crap (relatively small)
git clone git://git.codemadness.org/jscancer
Log
Files
Refs
README
LICENSE
---
clipcopy.js (764B)
---
1 // clipboard(text, [el])
2 // (if allowed, try to) copy text to clipboard.
3 // specifying el tries to insert the textarea before the element, this
4 // prevents the page from scrolling in some cases.
5 function clipcopy(text, el) {
6 var textarea = document.createElement("textarea");
7 textarea.value = text;
8 if (el == null)
9 document.body.appendChild(textarea);
10 else
11 el.parentNode.insertBefore(textarea, el);
12 textarea.focus();
13 textarea.select();
14 try {
15 document.execCommand("copy");
16 } catch (err) {
17 }
18 if (el == null)
19 document.body.removeChild(textarea);
20 else
21 el.parentNode.removeChild(textarea);
22 }
23
24 // copy the data-value from the specified element to the clipboard.
25 function clipcopy_datavalue(el) {
26 clipcopy(el.getAttribute("data-value") || "", el);
27
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.