I am building a web page and have run into something that would be nice to be able to do; set text to be copied to the clipboard when someone tries to copy an image, probably the same as the alt text. Is there any way with javascript/html that this can be done? If so, please explain.
Thanks for any help!
Edit: Basically, I want to let my users highlight the image, press control-c, and then have the alt text stored in their clipboard.
I am building a web page and have run into something that would be nice to be able to do; set text to be copied to the clipboard when someone tries to copy an image, probably the same as the alt text. Is there any way with javascript/html that this can be done? If so, please explain.
Thanks for any help!
Edit: Basically, I want to let my users highlight the image, press control-c, and then have the alt text stored in their clipboard.
Share Improve this question edited Jul 28, 2012 at 3:00 asked Jul 28, 2012 at 2:54 user1559041user1559041 6- Are you looking to just copy the alt text? Or HTML that contains the image and some sort of caption with it? – Brad Commented Jul 28, 2012 at 2:56
- Just to copy the alt text when someone highlights the image and copies it would be great. – user1559041 Commented Jul 28, 2012 at 2:58
- Normally no images get copied on pressing cttl + c when hovered on a image. So what you means by highlighted? – McLosys Creative Commented Jul 28, 2012 at 3:20
-
I think only IE supports
oncopy
for images and you'd probably need flash for the copying to clipboard part – Musa Commented Jul 28, 2012 at 3:25 - @McLosysCreative Hightlight as in clicking down and dragging over it, the way you would copy text. – user1559041 Commented Jul 28, 2012 at 12:26
4 Answers
Reset to default 5add attribute alt="text"
to your image
example:
<img alt="