Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
:P In response to this thread mainly. And so I don't lose how I did it.

function copytext(ext){
try {
if(!document.getElementById("te")){
var te = document.createElement("textarea");
te.id = "te";
te.style.display = "none";
document.body.appendChild(te);
}
var te = document.getElementById("te");
te.value = ext;
co = te.createTextRange();
co.execCommand("Copy");
alert("The code has been copied to your clip board.");
} catch(e){
prompt("Copy the code below to your clipboard using ctrl+c.",ext);
}
}


This'll only automatically copy the text in IE. In FF and other browsers it creates a popup containg the stuff to be copied, already highlighted, and then you just have to hit ctrl+c (as the instructions in the popup state).


Virtuoso

Virtuoso Avatar

****
Senior Member

271


May 2006
Haha, Smart. :P Good job. :)

newBookmarkLockedFalling