text value representing images in javascript
I wa开发者_如何学Cnt to use image files to represent a custom font, and it would copy the text value when selected and copied. is this possible with JavaScript?
I would look into alternatives. There is no need for images when it can be done completely cross-browser with something like Cufon or sIFR if Flash is an option.
Technically it would be possible with JavaScript, but it would be rather fragile. You would have to find a font that is "web-safe" (i.e. available on ~100% of computers) that scales more or less similarly to your custom font. Then you would have to overlay a SPAN element over the image (using absolute positioning) with this text in it, make it transparent and make sure it is at a font size similar to what is used in the image.
Messy to say the least.
Of course if you select an image and copy the selection, the alt text is copied, but I can't see this being very user-friendly. Besides, it can be pretty difficult to actually highlight just an image on a page.
精彩评论