views:

208

answers:

2

I've been working on sending text to an input element in Chrome and I noticed that, unlike in IE or FF, calling .focus() does not put the cursor in the text area. So does anyone know of an alternative for placing the cursor on a Chrome input element?

A: 
Samuel
Thanks guys, now it's working. Apparently calling dispatchEvent wasn't doing it, but calling .focus() directly does work!
Samuel
+1  A: 

I have no issues either. Here is an simple HTML file I have that works in Chrome:

<html>
<body>

<textarea id="ta1"></textarea>
<br />
<textarea id="ta2"></textarea>
<br />
<textarea id="ta3"></textarea>

<script>
document.getElementById("ta2").focus();
</script>

</body>
</html>

Are you putting the script section above or below the textareas?

Ascalonian