Click here to Skip to main content
16,018,418 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I create a site in which i need a copy to clipboard functionality.In a site ther is some code. if a user click on that code .the code will copy and can paste anywhere.


Suppose ABCED is my code and if click on ABCED then this code will copy....
I need a code or example through which run on all type of browser specially Mozilla or chrome
Posted
Comments
Sergey Alexandrovich Kryukov 18-Nov-13 1:44am    
Which clipboard, on a server side (as PHP works on server side)? But it would not make sense.
And you don't click on code... makes no sense at all...
—SA
enhzflep 18-Nov-13 6:54am    
No can do. You _can_ copy to the clipboard with JavaScript _if and only if_ using Internet Exploder er, I mean Explorer. But for a cross-browser solution, you need to use Flash.

1 solution

cannot do it in php since php is server side
only IE allows to do it even in client side
a good solution would be to auto select [highlight] the code once you click on its container
and then ask user to copy it

This implementation I've seen in many sites offering code hosting
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900