admin管理员组文章数量:1391955
I want to make the soft keyboard show on
$( document ).ready(function() {
....
});
here's my html code:
<form id="typerForm">
<input id="typer" style="position:relative; left:-100em;"/>
</form>
<div id="myInput" style="border:2px solid #4AA; width:6em; height:1em; font-size:2em"></div>
<div style="height:20em; background-color:#eee">
</div>
and here's my javascript code:
$('body').click(function() {
$('#typer').focus();
$('#typer').select();
});
$('#typerForm').submit(function() {
//alert("submit");
setTimeout("$('#typer').focus();", 1000);
return false;
});
$('#typer').bind('keyup', function(e) {
var input = $.trim($(this).val());
// some lines of code..
$('#myInput').text(input);
//...
//$(this).val('').focus(); // clean up
});
or you can look at my code here /
my code works to show the keyboard on mobile web browser when i click on somewhere or click on the input text. And what i want is show keyboard automatically when the page ready or finish loading
I want to make the soft keyboard show on
$( document ).ready(function() {
....
});
here's my html code:
<form id="typerForm">
<input id="typer" style="position:relative; left:-100em;"/>
</form>
<div id="myInput" style="border:2px solid #4AA; width:6em; height:1em; font-size:2em"></div>
<div style="height:20em; background-color:#eee">
</div>
and here's my javascript code:
$('body').click(function() {
$('#typer').focus();
$('#typer').select();
});
$('#typerForm').submit(function() {
//alert("submit");
setTimeout("$('#typer').focus();", 1000);
return false;
});
$('#typer').bind('keyup', function(e) {
var input = $.trim($(this).val());
// some lines of code..
$('#myInput').text(input);
//...
//$(this).val('').focus(); // clean up
});
or you can look at my code here http://jsfiddle/7urry794/
my code works to show the keyboard on mobile web browser when i click on somewhere or click on the input text. And what i want is show keyboard automatically when the page ready or finish loading
Share Improve this question edited May 23, 2017 at 14:32 adn asked May 23, 2017 at 7:15 adnadn 4303 gold badges7 silver badges21 bronze badges 1- Please provide code in your question. Else as soon as your link is broken, nobody will be able to re-use the help provided to solve your problem – Nuageux Commented May 23, 2017 at 8:52
2 Answers
Reset to default 3you can use below code to open keyboard on iOS or Android There are a couple of ways I know of to get around this:
prompt()
opens the keyboard
If you trigger the .focus()
from within a .click()
event (e.g. from opening your dialog), the keyboard shows up
Hope it might help
You can do this by calling focus()
then click()
on the input, but only if the script is initiated by user input. All attempts to get this to work from an onload handler with no user interaction FAILED :-( Beware of endless loops if your script is triggered by an onclick() on a containing element. The script below is working for me on Chrome for android 58 and Safari mobile 602.1, when called from an onclick().
function onSomethingOtherThanLoad(event){
// get the input
var target = document.getElementsByTagName("input")[0];
if (event.target != target) {
target.focus();
target.click();
}
}
本文标签: javascriptAuto Show Soft Keyboard on mobile web browserStack Overflow
版权声明:本文标题:javascript - Auto Show Soft Keyboard on mobile web browser - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744684046a2619587.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论