The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Code to copy text to clip board

2 posters

Go down

Code to copy text to clip board  Empty Code to copy text to clip board

Post by Sir. Mayo July 25th 2013, 9:23 pm

Hi,

I'm looking for a code that copies text to the users clip board when the button is pressed.

SO i want a button that when pressed its Copies a Email address to the users clip board. Any on know how to do this???
Sir. Mayo
Sir. Mayo
Forumember

Male Posts : 980
Reputation : 90
Language : English, Some french.
Location : you can also reach me on snoonet's irc server. I idle in #Techsupport Username is Vault108

http://sir-mayo.forumotion.com/

Back to top Go down

Code to copy text to clip board  Empty Re: Code to copy text to clip board

Post by Mr.EasyBB July 26th 2013, 5:00 am

Sir Mayo, with Google Chrome and Firefox this is not allowed, only with Internet Explorer is this allowed with code.

A code would look like:

Code:
  function select_all(obj) {
        var text_val=eval(obj);
        text_val.focus();
        text_val.select();
        if (!document.all) return; // IE only
        r = text_val.createTextRange();
        r.execCommand('copy');
    }

Then on the button you do

<input value="http://www.sajithmr.com" onclick="select_all(this)" name="url" type="text" />
avatar
Mr.EasyBB
Forumember

Posts : 71
Reputation : 9
Language : HTML/CSS/JS/JQUERY/MOOTOOLS

http://www.avacweb.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum