Browser frustrations

Earlier on I was writing some code that inserted some text into a textarea on a webpage. After the text has been inserted I needed the cursor to be at the end of the textarea so that the user could then type more text in afterwards without any messing around.

I thought it would be a simple matter, but it turned out to be quite frustrating.

Needed for all
var t = document.getElementById('add-comment');

Gecko (Firefox, Mozilla, etc.)

Webkit (Chrome, Safari, etc.)

Internet Explorer
t.setSelectionRange(t.value.length, t.value.length);

Is there some standard way of doing this that I’m unaware of? I think jQuery would be overkill for this one purpose.