// this code snippet causes Firefox to scroll the textarea to the beginning, // while the cursor position stays correctly (in the now scrolled off part of the textarea): myField.value = myField.value.substring(0, startPos) + myInsertText + myField.value.substring(endPos, myField.value.length);