Right now I use:
<body onLoad="document.getElementById('myinput').focus();">
but it doesn't seem to work on iPhone.
Right now I use:
<body onLoad="document.getElementById('myinput').focus();">
but it doesn't seem to work on iPhone.
Autofocus will never work on iPhone. Apple decided it is not in the interest of the user, so that is that.
The best way is to add autofocus=""
on the input in question. If you want to support older browsers to it is best to put the JS you've given at the end of the page instead of putting it in onload. If the page contains some images that take some time to load the onload will not fire directly and the user could already have selected another input and started typing, resulting in the text appearing in the wrong textbox once the onload fires, frustrating users.
So just put <script>document.getElementById('myinput').focus();</script>
just before </body>
The following code works for me
<input type="text" name="email" placeholder="E-Mail ID" autofocus></input>