Javascript专注于文件输入的浏览按钮 [英] Javascript focus on browse button of file input

查看:55
本文介绍了Javascript专注于文件输入的浏览按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试着眼于文件输入控件的浏览按钮.

I am trying to focus on the browse button of the file input control.

所以我有类似的东西

 <input type="file" name="upload" id="upload" >

在我拥有的javascript中

and in javascript I have

document.getElementById("upload").focus();

但是焦点仍然停留在文本字段上,并且只有在我按下Tab键之后才进入浏览按钮. 有什么办法可以编写脚本来将焦点设置在浏览按钮上?

but the focus remain on the text field and comes to browse button only after i hit tab. Is there a way that I could write a script to set the focus on the browse button?

感谢您的帮助!

推荐答案

无法完成.您几乎对文件上载字段的组成部分几乎没有任何控制,部分是出于安全原因,部分是因为标准未定义文件上载字段可能具有的组成部分.浏览器完全有可能在没有任何浏览"按钮的情况下呈现文件上传界面.

Can't be done. You have almost zero control over the constituent parts of a file upload field, partly for security reasons and partly because the standards do not define what constituent parts a file upload field might have. It is entirely possible the browser might render a file upload interface without any ‘Browse’ button.

这篇关于Javascript专注于文件输入的浏览按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆