.click()on< input type =" file" />在Firefox 3.6中不工作 - 任何解决方法? [英] .click() on <input type="file" /> does not work in Firefox 3.6 - Any workarounds?

查看:175
本文介绍了.click()on< input type =" file" />在Firefox 3.6中不工作 - 任何解决方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是一个示例:(实时演示此处

Here is a little example: (live demo here)

HTML:

<input id="file" type="file" />

Javascript:

Javascript:

$(function() {
    $("#file").click();
});

在Firefox 3.6.6中没有任何反应,而在IE7中,选择文件对话框打开。

In Firefox 3.6.6 nothing happens, while in IE7 the "Choose File" dialog box is opened.

任何想法如何在Firefox中打开选择文件对话框,而不点击浏览按钮?

Any ideas how to open the "Choose File" dialog box in Firefox without clicking on the Browse button ?

推荐答案

文件对话框突破了您的JavaScript代码运行的沙箱(访问HDD)。好的/安全的浏览器(=不是IE7)应该防止这个对话框通过脚本打开 - 它必须由一个真正的mouseclick打开。

The file-dialog breaks out of the sandbox your javascript code runs in (access to HDD). Good/secure browsers (= not IE7) should prevent that this dialog is opened via a script - it MUST be opened by a real mouseclick.

有些浏览器似乎允许

查看更多

See more in In JavaScript can I make a "click" event fire programmatically for a file input element?

这篇关于.click()on&lt; input type =&quot; file&quot; /&gt;在Firefox 3.6中不工作 - 任何解决方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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