Copy text to clipboard when clicking a link
Moderator: General Moderators
Copy text to clipboard when clicking a link
I need a script that, when a link is clicked, copies a text echoed by a php scipt. I dont know javascript, so i have no idea, but it would look something like this:
php has echoed a string in the script which says what to copy => user clicks the link => javascript copies the string from the php-script into clipboard => a popup pops up saying that the text is copied.
php has echoed a string in the script which says what to copy => user clicks the link => javascript copies the string from the php-script into clipboard => a popup pops up saying that the text is copied.
as a client side function it can't be done for two reasons:
1: javascript has no way to copy. only M$IE's version (jscript) which has a s**tload of non-standards, does. this willONLY WORK IN M$IE 5.0 (maybe 5.5) AND HIGHER
2: the aformentined jscript will only work with a form, when the button get the info from a textarea or text field
1: javascript has no way to copy. only M$IE's version (jscript) which has a s**tload of non-standards, does. this willONLY WORK IN M$IE 5.0 (maybe 5.5) AND HIGHER
2: the aformentined jscript will only work with a form, when the button get the info from a textarea or text field
well, ok, but i cant help you on the jscript coding, but ill help ya with anything else, just askm3rajk wrote:lol. that was my reaction too. would you like to see what i wrote figuring that i'll play with it after i get the site online to see if i can get it working properly?
maybe working together we can find something that'll get around M$SE's screwball antics and do what we want.
lol.vigge89 wrote:well, ok, but i cant help you on the jscript coding, but ill help ya with anything else, just ask ;)m3rajk wrote:lol. that was my reaction too. would you like to see what i wrote figuring that i'll play with it after i get the site online to see if i can get it working properly?
maybe working together we can find something that'll get around M$SE's screwball antics and do what we want.
here's what i have:
Code: Select all
<script language="Javascript">
function toClipboard(){
var text="/* text to copy goes here */";
var copyText=text.createTextRange();
if(confirm("Do you want to copy the link /* here i double the copy text */ to your clipboard?\n(this only works for M\$IE");){
copyText.execCommand("Copy");
alert("If using M\$IE, then you have just copied the link, /* again i give the code to be copied */ to your clipboard.");
}
}
</script>
Last edited by m3rajk on Tue Oct 28, 2003 10:18 pm, edited 1 time in total.