html focus 唤醒手机键盘,移动端 input 元素 focus 的时候调出键盘(自动触发 focus 事件的同时调出键盘)?...
UYOU
安卓我目前沒有遇到問題。然后直接使用input.focus()是無法在ios中調起鍵盤的,因為ios中input元素的focus必須由事件觸發。此外,如果模擬了觸摸事件,但是在setTimeout中延遲執行,也是不行的。這部分可以參考stackoverflow上的case:Mobile Safari Autofocus text field.來自FastClick團隊的大牛指出了IOS下input的獲取焦點存在這樣的問題:my colleagues and I found that iOS will only allow focus to be triggered on other elements, from within a function, if the first function in the call stack was triggered by a non-programmatic event. In your case, the call to setTimeout starts a new call stack, and the security mechanism kicks in to prevent you from setting focus on the input.綜上,要在ios中選中input并調起鍵盤,可以將focus調用包裝在一個用戶行為觸發的事件中,如點擊事件、表單onChange事件等。解決方案Trigger focus on input on iPhone programmaticallyShow keyboard on iOS automatically如果需要模擬觸發事件,可以參考manually trigger touch event
總結
以上是生活随笔為你收集整理的html focus 唤醒手机键盘,移动端 input 元素 focus 的时候调出键盘(自动触发 focus 事件的同时调出键盘)?...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 给机器人罗宾写一封英语回信_写一篇关于2
- 下一篇: Android开发之APP直播简介