【问题标题】:How to avoid focus on input box after page load页面加载后如何避免关注输入框
【发布时间】:2013-12-20 03:00:01
【问题描述】:

这是一个带有flash(图形)的页面上的场景和这样的表单:

  <form>
    Username: <input type="text" name="userName">
    Password: <input type="password" name="password">
  </form>

当此页面加载时,这些输入框会出现在所有图形之前。如果用户不等待图形加载并输入用户名,并且在输入密码的一半时,图形加载并且焦点设置到用户名字段 - 使密码的其余部分被输入在用户名字段中。没有 javascript 干扰这两个字段。我怎样才能避免这种情况?

【问题讨论】:

    标签: html focus


    【解决方案1】:

    试试这个,

    Username: <input id="username" type="text" name="userName">
    Password: <input id="password" type="password" name="password">
    
    $(function () {
       $('#username,#password').blur();
    });
    

    模糊功能可防止自动聚焦输入元素。确保没有其他函数将焦点设置在字段上

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-26
      • 1970-01-01
      • 1970-01-01
      • 2012-12-22
      • 1970-01-01
      • 1970-01-01
      • 2012-01-02
      • 2015-03-08
      相关资源
      最近更新 更多