在JavaScript中,是否可以通过编程方式启动文件浏览器对话框? [英] In JavaScript is it possible to launch a file browser dialog programmatically?

查看:120
本文介绍了在JavaScript中,是否可以通过编程方式启动文件浏览器对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个启动文件浏览器对话框的按钮,而不是使用< input type =file> 标签。

Instead of using the <input type="file"> tag I'd like to have a button that launches a file browser dialog.

我的第一个想法是有一个隐藏的文件输入标签和一个按钮。我使用按钮点击按钮触发隐藏文件输入的onclick,但我无法正常工作。

My first thought was to have a hidden file input tag and a button. I'd use the button click on the button to fire the onclick of the hidden file input, but I haven't been able to get this working properly.

所以问题是,这甚至可能吗?第二是有更好的方法来做到这一点,仍然能够以表格形式发回信息吗?

So the question is, is this even possible? And second is there a nicer way to do this and still be able to send the information back in a form?

这将是降级功能的底层(来自Flash)到JavaScript(我们的网站在没有JS的情况下不起作用))所以它必须只使用基本的JS和HTML。

This will be the bottom layer of degrading functionality (from Flash to JavaScript (our site doesn't work without JS)) so it has to work with just basic JS and HTML.

推荐答案

是的,通过不透明度(在大多数浏览器中)是可能的。 这是一个教程

Yes, it's possible (in most browsers) via opacity. Here's a tutorial.

这篇关于在JavaScript中,是否可以通过编程方式启动文件浏览器对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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