简体   繁体   English

选择时键盘不显示<input>仅限 iOS

[英]Keyboard doesn't show up when selecting <input> on iOS only

For a particular field on my website, the keyboard doesn't show up on my website when running it on Safari iOS.对于我网站上的特定字段,在 Safari iOS 上运行时,我的网站上没有显示键盘。 It works on the web and Android chrome.它适用于网络和 Android chrome。

The keyboard will only show up if I select the multitab button on safari, and return to the website again.只有当我在 safari 上选择多标签按钮并再次返回网站时,键盘才会显示。 Then the keyboard will show up when I select the field.然后当我选择该字段时键盘会出现。

What are the things that change when I select the multitab button which changes the input behaviour of the keyboard?当我选择改变键盘输入行为的多标签按钮时,有哪些变化?

Update:更新:

Before clicking the input text field (with readonly property):单击输入文本字段之前(具有只读属性):

<div class="form-cell password">
    <span class="label">Password</span><br>
    <input type="password" name="loginValidVO.password" maxlength="15" mandatory="true" autocomplete="off" readonly
        onfocus="this.removeAttribute('readonly');" class="placeholder" id="password">
</div>

After clicking the text field (will trigger the onfocus event and remove the 'readonly' property), however the keyboard still doesn't show up.单击文本字段后(将触发 onfocus 事件并删除 'readonly' 属性),但是键盘仍然没有显示。

<div class="form-cell password">
    <span class="label">Password</span><br>
    <input type="password" name="loginValidVO.password" maxlength="15" mandatory="true" autocomplete="off"
        onfocus="this.removeAttribute('readonly');" class="placeholder" id="password">
</div>

Do we need something to refresh the view so that the removal of input field readonly property will take effect?我们是否需要一些东西来刷新视图,以便删除输入字段只读属性生效?

Android works flawlessly with the code above, just wondering why it happens only on iOS device (both safari and chrome) Android 与上面的代码完美配合,只是想知道为什么它只发生在 iOS 设备上(Safari 和 chrome)

Try adding additional attribute for the touchstart event - ontouchstart , which executes the same javascript:尝试为touchstart事件添加附加属性 - ontouchstart ,它执行相同的 javascript:

<input type="password" name="extLoginValidVO.password" maxlength="20" mandatory="true" autocomplete="off" 
       ontouchstart="this.removeAttribute('readonly');" 
       onfocus="this.removeAttribute('readonly');" 
       class="placeholder"
       id="password"
       readonly>

You might want to keep onfocus too, since it's needed for desktop browsers.您可能也希望保持onfocus ,因为桌面浏览器需要它。 Here's the jsfiddle that I used: https://jsfiddle.net/u5g7t4c1/4/这是我使用的 jsfiddle: https ://jsfiddle.net/u5g7t4c1/4/

Where/When did you put the 'readonly' property on Input?你在哪里/什么时候把“只读”属性放在输入上?

It prevents the keyboard popsup.它可以防止键盘弹出。

Just use autocomplete="current-password" in password input and the problem will be solved!只需在密码输入中使用 autocomplete="current-password" 即可解决问题! :) :)

I had the same issue after trial and error for hours I found that in safari iPhone 7 for password type inputs autocomplete attribute should set with "current-password".经过数小时的反复试验,我遇到了同样的问题,我发现在 Safari iPhone 7 中,密码类型输入的自动完成属性应设置为“当前密码”。

<input type="password" name="password" autocomplete="current-password"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM