aboutsummaryrefslogtreecommitdiffstats
path: root/lib/clipboard.js
diff options
context:
space:
mode:
authorilya2010-01-03 23:27:08 -0800
committerilya2010-01-03 23:27:08 -0800
commit684715730414a26a8177d65730908acc0440158a (patch)
treeda3988bead413fe649f2ed97861f9dff60d6d731 /lib/clipboard.js
parent48fadb34a0cb596d69655e6979f9292084d3a0b2 (diff)
downloadvimium-684715730414a26a8177d65730908acc0440158a.tar.bz2
Implement 'y' -- yank (copy) the current tab's url to the clipboard.
Diffstat (limited to 'lib/clipboard.js')
-rw-r--r--lib/clipboard.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/clipboard.js b/lib/clipboard.js
new file mode 100644
index 00000000..1d414892
--- /dev/null
+++ b/lib/clipboard.js
@@ -0,0 +1,14 @@
+var Clipboard = {
+ // http://groups.google.com/group/chromium-extensions/browse_thread/thread/49027e7f3b04f68/f6ab2457dee5bf55
+ copy: function(data) {
+ var textArea = document.createElement("textarea");
+ textArea.style.position = "absolute";
+ textArea.style.left = "-100%";
+ textArea.value = data;
+
+ document.body.appendChild(textArea);
+ textArea.select();
+ document.execCommand("Copy");
+ document.body.removeChild(textArea);
+ }
+};