输入文件点击Chrome [英] Input File Click Chrome

查看:90
本文介绍了输入文件点击Chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我有一个类型为file和id为test的输入元素

当我在地址栏中输入:javascript:document.getElementById(test ).click()它会打开打开的文件对话框,以便用户可以决定要上传的内容。但是,如果将相同的确切行插入到文档中或在Chrome的控制台中完成,则不会显示打开的文件对话框。事实上控制台说click()函数是未定义的。有没有什么办法可以做到这一点?



因为它对任何其他浏览器都可以正常工作

HTTM:

 < DIV> 
< input type ='file'>
< div>

CSS:

  div {
height:1px;
overflow:hidden;

JS:

  $('div input')。click(); 

祝您好运...


Ok so I have an input element of type file and id "test"

When I put in the address bar: javascript: document.getElementById("test").click() it brings up the open file dialog so the user can decide what to upload. However if this same exact line is inserted into the document or done in the console of chrome it does not bring up the open file dialog. In fact the console says that the click() function is undefined. Is there any way in chrome to do this?

Cause it seem to work fine for any of the other browsers

解决方案

You should wrap file-input element to other (ex.:div): HTTM:

<div>
<input type='file'>
<div>

CSS:

div{
height:1px;
overflow: hidden;
}

JS:

$('div input').click();

Good luck...

这篇关于输入文件点击Chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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