How to insert the image at cursor position

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Roamer
    New Member
    • Dec 2012
    • 23

    How to insert the image at cursor position

    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):
    Code:
    function gimg(str) {var e = getRefById('Entry'), s = null, r = null; if(e) {if((s = document.selection) && s.createRange) {var repos = false; e.focus(); 
     if((r = s.createRange())) {if(r.text.length) {repos = false;}r.text = str;
     if(repos && s.empty) {s.empty();}}} else {e.value += str;}}
    }
    The html in my editor:
    Code:
    <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.
  • Roamer
    New Member
    • Dec 2012
    • 23

    #2
    Forget it

    Forget it, I'll not bother

    Comment

    Working...