--- WSuggest.js.bak 2006-08-16 11:41:39.000000000 +1000 +++ WSuggest.js 2006-08-16 16:57:05.000000000 +1000 @@ -167,13 +167,26 @@ } // otherwise, perform autocomplete. Method to use depends on browser. + // Internet Explorer version: if (objInput.createTextRange) { + // Series of steps to find the current cursor position: + objInput.focus(); + var oSel = document.selection.createRange(); + var selectionLength = oSel.text.length; + oSel.moveStart ('character', -objInput.value.length); + var cursorPos = oSel.text.length - selectionLength; + // only use autosuggest when we are at the end of the text field. + if (cursorPos != objInput.value.length) { return; } objInput.value = newText; var oRange = objInput.createTextRange(); oRange.moveStart("character", iStart); oRange.moveEnd("character", iLength - objInput.value.length); oRange.select(); - } else if (objInput.setSelectionRange) { + } + // Firefox / Mozilla version: + else if (objInput.setSelectionRange) { + // only use autosuggest when we are at the end of the text field. + if (objInput.selectionStart != objInput.value.length) { return; } objInput.value = newText; objInput.setSelectionRange(iStart, iLength); }