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 */
  	retrieveURL('/Pinnacle/pg/hrm/payRuleEngine?reqCode=getPositionForConstraint&id='+node.selectionStart,'RuleEngineBean','setExpression,messageDiv');
 	return node.selectionStart;
 }
 else if(!document.selection){
 	retrieveURL('/Pinnacle/pg/hrm/payRuleEngine?reqCode=getPositionForConstraint&id='+0,'RuleEngineBean','setExpression,messageDiv');
  	return 0;
 }/* to work in IE  */

 var c		= "\001";
 var sel	= document.selection.createRange();
 var dul	= sel.duplicate();
 var len	= 0;
 dul.moveToElementText(node);
 sel.text	= c;
 len		= (dul.text.indexOf(c));
 sel.moveStart('character',-1);
 sel.text	= "";
retrieveURL('/Pinnacle/pg/hrm/payRuleEngine?reqCode=getPositionForConstraint&id='+len,'RuleEngineBean','setExpression,messageDiv');

}

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.

Regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.