首页 > input autofocus 手机上面无效

input autofocus 手机上面无效

如题
电脑上面是ok的,手机上面就无法autofocus了,
这个周末解决?


不知道你想表达的是什么意思,是打开这个页面input自动获取焦点么?还是手机点击一个input后使得该input获取焦点?

如果是第一种情况的话:

<input autofocus="true" placeholder="请输入文字">

如果是第二种情况的话:

<input id="input" placeholder="请输入文字">
<script language="javascript" type="javascript/text">
    function isFocus(){
        var input = document.getElementById('input');
        if(input == document.activeElement){
            console.log('你选中了input');
        }else{
            console.log('没有选input');
        }
    }
</script>  

手机端测试代码:

<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="description" content="Input autofoucs : 如何让手机显示时自动获取焦点">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Input autofoucs</title>
<style>
  body{
    text-align: center;
  }
  input {
    padding:20px;
  }
</style>
</head>
<body>
<p>测试手机是否自动获取焦点</p>
<input autofocus="true" type="text" placeholder="输入您要输的信息" id="input">
</body>
</html>  

测试地址:http://yulei521.github.io/input_autofocus/(手机可以打开链接查看)


苹果手机上无效,不自动显示光标,怎么办啊?

【热门文章】
【热门文章】