admin管理员组文章数量:1402962
I want to be able to show keyboard on mobile browser (e.g. Android) after navigating to the page. I have already seen some workarounds:
Show virtual keyboard on mobile phones in javascript
Can I trigger Android soft keyboard to open via javascript ( without phonegap )?
Showing Android's soft keyboard when a field is .focus()'d using javascript
But all of these examples work only if user tap somewhere. It allows to trigger focus()
from within the click()
. Does someone know if there any way to do the same thing but without user clicking?
I've tried to trigger click programmatically but it also not working. /
I want to be able to show keyboard on mobile browser (e.g. Android) after navigating to the page. I have already seen some workarounds:
Show virtual keyboard on mobile phones in javascript
Can I trigger Android soft keyboard to open via javascript ( without phonegap )?
Showing Android's soft keyboard when a field is .focus()'d using javascript
But all of these examples work only if user tap somewhere. It allows to trigger focus()
from within the click()
. Does someone know if there any way to do the same thing but without user clicking?
I've tried to trigger click programmatically but it also not working. http://jsfiddle/alex_myronov/e5JcP/10/
Share Improve this question edited May 23, 2017 at 11:52 CommunityBot 11 silver badge asked Jan 10, 2014 at 21:32 alex.mironovalex.mironov 2,9526 gold badges29 silver badges42 bronze badges 1- EDIT: sorry misread the question.stackoverflow./a/12113168/2558344 Everything you would need is there^. – Aashir Commented Jan 10, 2014 at 21:37
2 Answers
Reset to default 2My current answer to this is no, can't be done. The script that calls focus() click() on an input needs to be running with user context, ie. triggered by a user interaction. After fairly dedicated fiddling, I've found no way round this.
I managed to successfully open the virtual keyboard by just calling focus() method of the input.
It works in my app both on android 2.3 and 4.1.
I think the trick is that you have to wait untill the page is pletly rendered before you call focus().
My app is using jquery mobile and I call focus() when the pageshow event is triggered:
$("#myPage").on("pageshow", function( event ) {
$("#myPage").find('input:first').focus();
} );
Or maybe it's working because I'm in a phonegap app?
本文标签: Show android keyboard from javascriptStack Overflow
版权声明:本文标题:Show android keyboard from javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744378011a2603358.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论