SetFocus does not work on iPad

We found that this code works on a PC with: IE, Safari, and FireFox. However, on an iPad or iPhone with Safari, it does not focus on the text field. We cannot touch the screen and click the text box, we need autofocus. Any tips here?

thank!

<script language='JavaScript'>
<!--
function SetFocus()
{
    document.form1['txtCode'].focus();
}
window.onload = SetFocus;
// -->
</script>
+3
source share
2 answers

Unfortunately, Mobile Safari does not seem to support this design behavior.

http://www.quora.com/Mobile-Safari-iPhone-or-iPad-with-JavaScript-how-can-I-launch-the-on-screen-keyboard

+2
source
<body onload="document.getElementById('txtCode').focus();">
    <form>
        <input type="text" value="Text Here" name="txtCode" id="txtCode" />
    </form>
</body>

try it

-3
source

Source: https://habr.com/ru/post/1794743/


All Articles