I doubt this is a great cross-browser solution, however it does seem to be a work around in Firefox. I originally tried it by simulating the right arrow-key press, but didn't have any luck.
function setCursor(id)
{
var elem = document.getElementById(id);
elem.focus();
elem.setSelectionRange(elem.value.length, elem.value.length);
// Trigger a "space" keypress.
var evt = document.createEvent("KeyboardEvent");
evt.initKeyEvent("keypress", true, true, null, false, false, false, false, 0, 32);
elem.dispatchEvent(evt);
// Trigger a "backspace" keypress.
evt = document.createEvent("KeyboardEvent");
evt.initKeyEvent("keypress", true, true, null, false, false, false, false, 8, 0);
elem.dispatchEvent(evt);
}
More info on initKeyEvent here.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…