I am creating a PhoneGap app. I have to set focus on a textarea on the pageload:
I have used
<body onload="newNoteOnLoad();">
<div class="container">
<div class="header">
<h1 id="noteHeader">
New Note</h1>
<a href="Books.html" class="back" id="back"></a><a href="#" class="done" id="bttnDone" onclick="addNewNote();">
</a>
</div>
<div class="mainhelp">
<p>
<textarea id="txtNote" cols="115" rows="15"></textarea>
</p>
</div>
</div>
<script type="text/javascript">
alert('focus');
document.getElementById("txtNote").focus();
</script>
in pageload function. But it didn’t work for me. Can anyone help me out please?
If you want the keyboard to show you will have big trouble cause the focus event get’s fired async. I have only had luck getting the keyboard up on user input’s such as
touchstart,touchend&click