Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
260 views
in Technique[技术] by (71.8m points)

jquery - Cross Browser Issue. Need advice

I designed an input upload box using jquery that i googled somewhere, problem is the "Browse" Button is not working(not clickable) on IE. Can anyone take a peek on the code and help me what i should do or tweak for this to work on IE? Thanks a lot. I've included the html/css/js files on jsfiddle bellow.

jSFiddle

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The "browse" button that you added doesn't work in IE 7/8/9, Chrome, or Firefox. You may have a different experience, which reinforces the point I'll try to make.

It's better to either use a Flash-based file upload to completely replace the default UI (I believe GMail still does this), or just leave the default input alone, ugly/inconsistent as it may be. There are many hacks to style file uploads, but no real solutions (at least that I've come across).

The closest thing I have found to a pure HTML/CSS solution was to overlay a styled button on top of the file input's "browse" button and hide the rest of it. I then mimicked async capabilities by placing the whole thing inside of an IFRAME. This solution did/does still work but I wasted hours tweaking it visually, added a bunch of extra code to hook the IFRAME to the containing page, and increased the complexity of the overall solution. And the next update to any browser may break it.

HTML 5 does offer much more flexibility around the file upload process (see here) but such solutions aren't universally supported yet and still don't necessarily address aesthetic concerns.

Drag and drop capabilities may be useful to you as you can hide the file input altogether. You may be able to use a solution like this in newer browsers and degrade to a standard file input on older browsers which do not support it.

Another example with progressive enhancement.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...