javascript - characters inserted after cursor firefox -


I'm trying to create a WYSIWYG editor. At some point I need to change the position of the cursor. I use this code for that purpose:

  var sel = window GetSelection (); Var range = document.createRange (); Range.setStart (startNode, startoffset); Range .setEnd (endnode, endoffet); Sel.removeAllRanges (); Sel.addRange (range);  

A new condition is expected, however, when I start typing the text, it appears after the cursor, and vice versa. For example if I type test then it is | Tset looks like .

This bug occurs in Firefox 31.0, while it is working fine in Chrome Do you know what might be the reason for this bug and how to fix it?

Edit:

I came to know how to fix it: The problem came from the fact that element startNode The bug that was not fixed could be fixed like this:

  var sel = window.getSelection (); Var range = document.createRange (); Range.setStart (startNode, startoffset); Range .setEnd (endnode, endoffet); $ (StartNode) .focus (); Sel.removeAllRanges (); Sel.addRange (range);  


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -