【问题标题】:tabindex and <input type="file" /> different in Firefox and IEtabindex 和 <input type="file" /> 在 Firefox 和 IE 中不同
【发布时间】:2009-08-20 10:53:34
【问题描述】:

渲染时:

<input type="file" />

你得到一个盒子和一个按钮,对吧? (至少在 Firefox 和 IE 中。)

一方面,在 Firefox 中,您只能通过 tab 键(聚焦)按钮,但在 IE 中,您可以通过 tab 键(聚焦)框和按钮。

另一方面,我想让 IE 表现得像 Firefox,我的意思是,我需要摆脱框焦点。想想用户在键盘上导航。

(原因是因为&lt;input type="file" /&gt; 不可见。相反,带有背景图像的&lt;div&gt; 会伪装成&lt;input type="file" /&gt;。)

【问题讨论】:

    标签: jquery tabindex file-io


    【解决方案1】:

    如果你想推迟到 div,为什么不在提交时附加一个 OnFocus() 事件,并在函数内调用 div 上的focus() 事件函数:

    $("#MySubmit").focus(function(){
      $("#MyDiv").focus();
    });
    

    【讨论】:

    • div 能获得焦点吗?无论如何,如果我在 div 处于焦点时按回车键(通过键盘导航),我不会得到任何结果。出于安全原因,如果我在输入文件按钮上单击(或按回车键)以外的任何其他操作,我将无法打开浏览对话框。所以,这样的事情是行不通的: $("#MyDiv").click( function () { $("#MySubmit").click(); }
    猜你喜欢
    • 2017-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-30
    • 2015-03-12
    相关资源
    最近更新 更多