问题描述
然而,我知道'自动对焦'属性是'不可以' t支持移动Safari浏览器。我需要自动对焦的原因是因为我正在开发一个Web应用程序,所以基本上需要用户使用他们的蓝牙扫描器将输入发送到一个PHP页面,然后发布该数据(因此,简单地离开页面)。回来后,我希望箱子能够再次聚焦,为下一次扫描做好准备。正如你可能已经猜到的那样,我的客户希望使用iPad / iPhone。
输入本质上只是一个键盘楔,一系列键盘笔画将发送到任何地方
我尝试过使用下面的JavaScript和jQuery代码无济于事;
<$ p $ ();
$(#scan-input).focus();
});
没有工作。和;;
function formfocus(){
document.getElementById('scan-input')。focus();
}
window.onload = formfocus;
放置在页面底部时无法使用。
我试过寻找这个问题并找到了;
但是没有任何有用的信息被返回。
现在当我使用上面提到的JavaScript和jQuery代码时,它实际上在我的Web浏览器上工作,但是,不在iPad或iPhone上(我正在使用作为预防措施,iPhone每次都会通过隐身窗口进行测试以清除缓存)。
有谁知道如何将焦点集中到iPad / iPhone上的文本输入框为了可用性的原因,出于可用性原因,Safari(iPhone / iPad)忽略了所有focus()函数
I'm trying to create a web application that automatically focuses the text input box upon page load.
However, I know that the 'autofocus' attribute isn't supported in mobile safari. The reason I need it to autofocus is because I am developing a web application so to say, and it basically requires the user to use their bluetooth scanner to send input to a PHP page that then POSTs that data (and hence, leaves the page briefly). Upon return, I wish for the box to be focused again, ready for the next scan. And as you may have guessed, my client wishes to use an iPad/iPhone.
The input is essentially just a keyboard wedge, a series of keyboard strokes will be sent wherever the focus is.
I've tried using the JavaScript and jQuery code below to no avail;
$( document ).ready(function() {
$( "#scan-input" ).focus();
});
Didn't work. And;
function formfocus() {
document.getElementById('scan-input').focus();
}
window.onload = formfocus;
Didn't work either when placed at the bottom of the page(s).
I've tried searching for this problem and found;How can you autofocus on a form field in iPhone Safari?
But there wasn't any helpful information returned either.
Now when I use the JavaScript and jQuery code posted above, it does infact work on my web browsers but again, not on the iPad or iPhone (I'm using an iPhone for testing with an incognito window each time to clear cache as a precaution).
Does anyone know a way to force the focus to a text input box on iPad/iPhone?
For usability reasons all the focus() functions are ignored by Safari in iPhone/iPad for usability reasons
这篇关于iPhone / iPad上的自动对焦表单元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!