Autocomplete uses selectionStart which is not supported in IE


I noticed that the autocomplete behavior JavaScript uses the selectionStart-attribute, which is not supported in IE. This is the part where it's used (line 256):

_getCursorIndex: function() {
return this.get_element().selectionStart;

The only reason (almost) everything still works is because it's only used to find the word that needs to be autocompleted. The default behavior is to return everything that has been typed (unless there are delimiter characters, which work correct too) and element.value.substring(0, undefined) will return exactly that.

I tried to create an IE-way of calculating the cursor index using ranges and bookmarks, but this doesn't seem to allow to calculate the cursor index more than once:

var el = this.get_element();
var bookmark = "~";
var range = document.selection.createRange();

while(el.value.indexOf(bookmark) != -1)
bookmark = bookmark + "~";
var orig = el.value;
range.text = bookmark;
result = el.value.search(bookmark);
el.value = orig;

If I execute this the first time it works correct, but the second time it returns the end position of el.value

Closed Mar 20 at 1:56 PM by fadilmamedov
This attirbute is only unsupported in Internet Explorer versions 8 and lower. Starting with v15.1 of Ajax Control Toolkit, we refused to support old versions of browsers. This applies primarily to earlier versions of Internet Explorer (7 and earlier).