最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Can we add an image to a text area? If so how? - Stack Overflow

programmeradmin1浏览0评论

I have a text area and when the user clicks a button say something like insert an image button the user selects the image to be uploaded and then i would like to add this image to the text area and the user can continue editing the text area, just like what orkut does. How do we achieve such functionality?

I have a text area and when the user clicks a button say something like insert an image button the user selects the image to be uploaded and then i would like to add this image to the text area and the user can continue editing the text area, just like what orkut does. How do we achieve such functionality?

Share Improve this question asked Jun 12, 2011 at 19:09 sasidharsasidhar 7,76216 gold badges51 silver badges78 bronze badges 3
  • 1 possible duplicate of HTML : Is there any way to show images in a textarea? – Aron Rotteveel Commented Jun 12, 2011 at 19:12
  • You can add a background image with CSS, but I don't think that is what you want. – MooGoo Commented Jun 12, 2011 at 19:21
  • It might be a bit over the top for your needs, but it's customisable. Take a look at TinyMCE: tinymce.moxiecode. – Bojangles Commented Jun 12, 2011 at 19:26
Add a ment  | 

3 Answers 3

Reset to default 4

You can't display an image directly inside a textarea control.

The closes you can get is overlay an image on it, but it will not be part of the information in the textarea. That is, text will not flow around it and when posting the form it will not be included in the data for the textarea.

Perhaps a writable div (content editable) would suit your purposes better.

I don't believe this is possible. You should look into using a content editable div.

I don't think Orkut actually does what you are talking about either. Looks like they are doing the same thing that stackoverflow does - using a wysiwyg editor, albeit a nicely dressed up or homegrown version. TinyMCE and FCKeditor are the two I'm most familiar with. There are a few leads on this page too: html editor alternative besides tinyMCE

发布评论

评论列表(0)

  1. 暂无评论