在加载时显示输入文件对话框? [英] Show input file dialog on load?

查看:34
本文介绍了在加载时显示输入文件对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个用于更改图像的对话框.我希望它立即被调出,而不是让用户单击文件输入字段.输入字段只是一个:

I'm making a dialog for changing an image. Instead of having the user to click the file input field I want it to be brought up immediately. The input field is simply a:

<input type="file">

有没有办法在页面加载时显示它?

Is there a way to display it when page is loaded?

如果有角度的方法,则加分.

Bonus points if there is an angular way of doing it.

推荐答案

如上所述 此处 只有 Internet Explorer 允许以编程方式打开文件上传对话框.所以简短的回答是否定的,没有办法在页面加载时自动打开文件上传对话框.

As described here only Internet Explorer allows for programmatic opening of the File Upload dialog. So the short answer is no, there is no way to automatically open the File Upload dialog on page load.

您可能考虑的长答案是,您可以在用户点击 任何东西.您更喜欢 AngularJS 解决方案的事实告诉我们,您正在编写一个单页应用程序.此外,我认为您不需要在应用程序首次加载时显示文件上传"对话框.您很可能需要它来显示after 一些用户交互 - 在用户点击某些东西之后.使用 此处 中的 AngularJS 指令,这些东西可能看起来像任何东西,但不是文件输入.单击时(相同的用户交互),您还可以切换到 AngularJS 应用程序中的另一条路径,有效地模拟用户导航到另一个页面并自动向他显示文件上传对话框.

The long answer that you might consider is that you can show it when the user clicks on anything. The fact that you prefer an AngularJS solution tells us that you are writing a Single Page Application. Also, I don't think you need to show the File Upload dialog when the app first loads. You most likely need it to show after some user interaction - after the user clicks on something. That something, using the an AngularJS directive from here, could look like anything but be a file input. On click (the same user interaction) you can also switch to another route in your AngularJS app, effectively simulating a user navigating to another page and automatically presenting him the File Upload dialog.

这篇关于在加载时显示输入文件对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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