View Full Version : DHTML: Cursor Positioning within iframe

02-18-2006, 11:12 AM
Hello, I wrote a piece of code to update code highlight in real time when a key is pressed... This works perfect with MSIE but I can't do the same with Mozilla/Firefox etc...
The problem in mozilla is to keep cursor position (it put the cursor always on the start). Anybody can Help me ?
Here's the code:

//here I save the cursor position
var rng = document.getElementById('myEditor').document.selection.createRange();
var position = { left : rng.offsetLeft, top : rng.offsetTop};
// now I get the whole content of the body
content=uncolorTags(content); // uncolor the tags (remove spans) (some string.replaces)
content=colorTags(content); // here I recolor the tags (re create spans) (some string.replaces)
// now I restore the updated content
// here I restore cursor position
rng.moveToPoint(position.left, position.top);