javascript - HTML5 initial pop-up keypad
PHP中文网
PHP中文网 2017-06-15 09:22:43
0
1
912

Please tell me, God, let the small keyboard of the HTML5 page pop up when the page first comes in.
ps: There is input in the page!
ps: Don’t tell me what focus to get. I’ve tried it all but it doesn’t seem to work. It doesn’t work on Android or Apple. Unless you click on it. . .

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
迷茫

Making the small keyboard pop up can only be activated through input`focus, so when you enter the page, just let it automatically focus`.
You can use the autofocus attribute in html5. Usually this setting is enough.

<input type="text" name="fname" autofocus="autofocus" />

There is no problem on Android, but Safari on the mobile side does not support the autofocus attribute by default, and only events triggered by the user can make focus methods take effect, so we can only simulate a fake one. autofocus:

<input type="text" id="focus" />
document.addEventListener('touchstart',function(e){
  e.preventDefault();
  console.log('touched!');
  document.getElementById('focus').focus();
});

Online Demo

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template