i am using a JS code to obtain the cursor position on a text area..it works botyh in Mozilla and IE..But the problem is when am using this in IE, am getting an alert box which has the contents like [object] ...the code is like this

function getPositionForConstraint(node) {

 if(node.selectionStart) {/* To work in mozilla */
 	return node.selectionStart;
 else if(!document.selection){
  	return 0;
 }/* to work in IE  */

 var c		= "\001";
 var sel	= document.selection.createRange();
 var dul	= sel.duplicate();
 var len	= 0;
 sel.text	= c;
 len		= (dul.text.indexOf(c));
 sel.text	= "";


the problem occur in last statement in which a method is called through ajax...
If it is not called through ajax, then no problem...
can u pls help me...

Hello ajithraj, your:

var c = "\001";

is returning "" character.

I'm not sure if "" is meant to be treated as a new-line character, nor if it is being treated as such. But I expect that, if this code is being passed as content of a html string - it will be dropped somewhere between passes.

I guess, that's because "innerHTML" interface on IEs has a correct meaning: a HTML code! While others might treat it as if it was "innerText" (that is: a plain text string). And because of that, your code might suffer from content normalization on its trip back.


This article has been dead for over six months. Start a new discussion instead.