Quantcast
Channel: Internet Explorer Web Development forum
Viewing all articles
Browse latest Browse all 3527

IE8 - how to move caret to the end of a text field and make the end visible

$
0
0

Hi,

The question below on stack overflow describes exactly what I'm trying to accomplish:

http://stackoverflow.com/questions/2692009/move-caret-to-the-end-of-a-text-input-field-and-make-the-end-visible

Basically, the question is to move cursor / caret to end of input field AND make the final characters visible - including the caret.  There are multiple code samples that move the cursor to the end of text in a text field, but few (aside from the one above) that make the final characters and the caret visible.  The code in the stack overflow question works for Chrome and possibly for IE9+ but not for IE8; createEvent is not available in IE8.  I tried to modify the code sample like so, to work with IE 8:

window.setTimeout(function() {
                e = document.createEventObject("KeyboardEvent");
                e.keyCode = 32;
                //textfield.fireEvent('onkeypress', e);
                textfield.fireEvent('onkeydown', e);
                textfield.fireEvent('onkeyup', e);
                textfield.blur();
                textfield.focus();
            }, 2000);

I put event handlers for keyup/keydown events and the above code does cause console.log statements to show up.  However, it doesn't work to actually scroll the text into view.

Please advise how to get this working in IE 8.

Thank you!

Notre


Viewing all articles
Browse latest Browse all 3527

Trending Articles