Input FileUpload autofocus 属性

定义和用法

autofocus 属性设置或返回文件上传按钮是否应在页面加载时自动获得焦点。

此属性反映 HTML autofocus 属性。

另请参阅:

HTML 参考手册:Sifat autofocus <input> HTML

实例

确定文件上传按钮是否会在页面加载时自动获得焦点:

var x = document.getElementById("myFile").autofocus;

亲自试一试

语法

返回 autofocus 属性:

fileuploadObject.autofocus

设置 autofocus 属性:

fileuploadObject.autofocus = true|false

属性值

�述
true|false

Specify whether the file upload button should gain focus when the page loads.

  • true - The file upload button gains focus
  • false - Default. The file upload button does not gain focus

Technical Details

Return value: Boolean value, if the file upload button automatically gains focus when the page loads, it returns true; otherwise return false.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support