469,913 Members | 2,022 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,913 developers. It's quick & easy.

How to insert the image at cursor position

23
I have an insertion of an image into my editor. It works very well, but...

The image only inserts after all the text.

How can I insert the image at the cursor position?

The Javascript in a .js file (not needed for this query):
Expand|Select|Wrap|Line Numbers
  1. function gimg(str) {var e = getRefById('Entry'), s = null, r = null; if(e) {if((s = document.selection) && s.createRange) {var repos = false; e.focus(); 
  2.  if((r = s.createRange())) {if(r.text.length) {repos = false;}r.text = str;
  3.  if(repos && s.empty) {s.empty();}}} else {e.value += str;}}
  4. }
The html in my editor:
Expand|Select|Wrap|Line Numbers
  1. <img src="/$bdir/allims/$ifl" class="imtn"  onclick="gimg('\\n<img src="\/$bdir\/allims\/$ifl"  border="0" title="$ifl" alt="$ifl"  class="blim">\\n')">
Thanks for any help.
Jul 13 '20 #1
1 2358
Roamer
23
Forget it, I'll not bother
Jul 14 '20 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Thomas | last post: by
2 posts views Thread by Matt Tapia | last post: by
1 post views Thread by Matt Tapia | last post: by
2 posts views Thread by gsb58 | last post: by
2 posts views Thread by swetha | last post: by
2 posts views Thread by Roamer | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.