ie issue: the start position on the text field is not correct in internet explorer
===

I'm trying to get the right caret position of a text field when a user clicks on an html tag, it works in everything except in the latest Internet Explorer.  Here is the jquery code:

    $.fn.extend({
			insertAtCaret: function(myValue){
				var obj;
				if( typeof this[0].name !='undefined' ) obj = this[0];
				else obj = this;
				if ($.browser.msie) {
					obj.focus();
					sel = document.selection.createRange();
					sel.text = myValue;
					obj.focus();
				}
				else if ($.browser.mozilla || $.browser.webkit) {
					var startPos = obj.selectionStart;
					var endPos = obj.selectionEnd;
					var scrollTop = obj.scrollTop;
					obj.value = obj.value.substring(0, startPos)+myValue+obj.value.substring(endPos,obj.value.length);
					obj.focus();
					obj.selectionStart = startPos + myValue.length;
					obj.selectionEnd = startPos + myValue.length;
					obj.scrollTop = scrollTop;
				} else {
					obj.value += myValue;
					obj.focus();
				}
			}
		})

basically it just gets the last caret position in a text input.  But it doesn't work like that in IE, any suggestions very helpful.