Auto open file input on IE

时光总嘲笑我的痴心妄想 提交于 2019-12-02 11:34:28

问题


Is it possible to auto open the file input on IE?

If you do

$(input).click();

IE doesn't submit the form. Maybe i can get its value somehow?

$(input).val()

Doesnt work, this will give you fakepath.

Any Idea about this? Cloning does also not work. Another possibility woudl be, to place the open button somwhere else on the page, without the input box for the path.

Is anything like this possible somehow? I have some img's and if you click on these images a file browser should pop up. Maybe theres some plugin i could use? Anything?

Trying out stuff for hours now.


回答1:


You can't get the path for security purposes .. but you can use a workaround solution to hide the traditional input element behind your custom design , like the following example http://www.quirksmode.org/dom/inputfile.html




回答2:


Call $(input).focus().click();

Tested in Firefox 10 and IE9.



来源:https://stackoverflow.com/questions/9516253/auto-open-file-input-on-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!