相关疑难解决方法(0)

移动Safari自动对焦文本字段

在Mobile Safari中,在设置延迟时间后,我无法将注意力集中在文本字段上.我附上一些展示问题的示例代码.如果单击该按钮,则触发.focus(),一切都按预期工作.如果你把焦点放在回调上,比如setTimeout函数,那么它只能在移动safari中失败.在所有其他浏览器中,有一个延迟,然后焦点发生.

令人困惑的是,即使在移动游猎中,也会触发"focusin"事件.这个(和SO中的〜类似〜评论)让我觉得它是一个移动的safari bug.任何指导都将被接受.

我已经在模拟器和iPhone 3GS/4 iOS4上进行了测试.

示例HTML:

<!DOCTYPE html> 
  <html lang='en'> 
    <head> 
      <title>Autofocus tests</title> 
      <meta content='width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0' name='viewport'> 
      <meta content='yes' name='apple-mobile-web-app-capable'> 
    </head> 
    <body>
      <h1> 
        Show keyboard without user focus and select text:
      </h1> 
      <p> 
        <button id='focus-test-button'> 
          Should focus on input when you click me after .5 second
        </button> 
        <input id='focus-test-input' type='number' value='20'> 
      </p> 
      <script type="text/javascript"> 
        //<![CDATA[
        var button = document.getElementById('focus-test-button');
        var input  = document.getElementById('focus-test-input');

        input.addEventListener('focusin', function(event) {
          console.log('focus');
          console.log(event);
        });

        button.addEventListener('click', function() {
          // *** If …
Run Code Online (Sandbox Code Playgroud)

javascript focus mobile-safari autofocus

55
推荐指数
2
解决办法
7万
查看次数

ipad上的JQuery focus()方法

可能重复:
iPad HTML焦点

有谁知道如何从jquery获取focus()方法在ipad上工作,或者可能是一种解决方法?我正在尝试做的是让键盘弹出一个网页,因为我有jquery捕获击键来执行事件.但是,如果页面上没有文本框,我不知道如何弹出键盘.现在我在页面上有文本框,我正在尝试使用jquery将焦点设置到文本框,以便弹出键盘.最重要的是,我将文本框样式设置为display:none,以便焦点转到文本框但是没有看到,因此功能似乎有效.但是,在ipad上打破了focus()!谁能帮我?

jquery focus ipad

11
推荐指数
2
解决办法
2万
查看次数

在ipad html5网站中使用键盘自动对焦

我正在开发一个html5应用程序,它将在自助服务终端模式的iPad上使用.用户必须做的第一件事是登录,所以当主页加载时,我希望屏幕键盘弹出焦点在第一个字段中.

我已经尝试了所有我能想到的变体,包括

  • html5 <输入自动对焦>属性
  • 在window onload中调用document.getElementById("nameFirst").focus()
  • 与前一个相同,但是onload调用一个timer方法来稍后调用焦点调用

谁有人想出如何使键盘自动出现?

html5 ipad

5
推荐指数
1
解决办法
7012
查看次数

JQuery keyup()keydown()和keypress()不支持iPad和蓝牙键盘

我遇到麻烦keyup(),keydown()keypress()事件在iPad上运行.当我连接无线蓝牙键盘并尝试使用键盘输入时会出现问题 - 事件不会触发.我尝试在iPad上使用Safari和Chrome(iOS 6.1).这个相同的HTML在桌面上的Firefox,Safari,Chrome等中运行良好.有没有办法更改此代码,使其在平板电脑上工作?我检查了document.activeElement,它似乎是文件正文,这是正确的.

<html>
    <head>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script>
            $(document).ready(function() {
                $(document).keyup(function(event) {
                    document.getElementById("output").innerHTML = document.getElementById("output").innerHTML + ("keyup " + event.which) + "<br>";
                });
                $(document).keydown(function(event) {
                    document.getElementById("output").innerHTML = document.getElementById("output").innerHTML + ("keydown " + event.which) + "<br>";
                });
                $(document).keypress(function(event) {
                    document.getElementById("output").innerHTML = document.getElementById("output").innerHTML + ("keypress " + event.which) + "<br>";
                });
            });
        </script>
    </head>
    <body>
        <div id="output"></div>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

javascript jquery bluetooth ipad ios

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

ipad ×3

focus ×2

javascript ×2

jquery ×2

autofocus ×1

bluetooth ×1

html5 ×1

ios ×1

mobile-safari ×1