Forum Moderators: open

Message Too Old, No Replies

InnerHTML doesn't work.

         

cm_eriksson

2:15 pm on Oct 8, 2005 (gmt 0)



Why doesn't "innerHTML" work, while "text" does in the following code:

function insertTextAtCursor() {

var TextEditor=document.getElementById("TextEditor");
var FileName=document.getElementById("myList").value;

TextEditor.focus();
TextEditor=document.selection.createRange();

TextEditor.innerHTML += "<a href="+FileName+">"+FileName+"</a>";

}

innerHTML works when i skip the "TextEditor.focus();"
and
"TextEditor=document.selection.createRange();"

Please advice... it's annoying :)

RonPK

8:05 pm on Oct 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello cm_eriksson, welcome to WebmasterWorld!

What are you trying to achieve?

Bernard Marx

7:45 am on Oct 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



TextEditor=document.selection.createRange();

You have now assigned the variable, TextEditor, to the range returned by createRange.
You've "lost" the element.