开发者

Why is <input type="file"> box grey in IE8?

Can anyone explain why my input type="file开发者_Go百科" is greyed out in IE8 but not IE7. It's still usable, but you can't actually type in the box any more.

<INPUT id="fil1" type="file" size="44" name="fil1" runat="server">

IE7:

Why is <input type="file"> box grey in IE8?

IE8:

Why is <input type="file"> box grey in IE8?


<input type='file'> is treated as a special case input field in all browsers. It looks different in pretty much every browser, and it can't easily be styled using CSS.

The reason for this is that the browsers consider it to have security issues, for example, where users may upload files without realising it. They therefore enforce a standard look and feel for it, so that the field will always be recognised for what it is. They also prevent CSS and Javascript from having access to the field so that they cannot modify the how it looks or alter the value of it.

In the case of IE8, the browser developers have decided that the only way the user should be allowed to access the field is via the file selector button. This is a concious decision by the IE developers to increase security. There's nothing you can do about it.

For the sake of curiosity, you should try seeing how <input type='field'> is rendered in other browsers - Firefox, Safari, Chrome, Opera... you'll be surprised by how different they all are in how they render this. It's probably the single most inconsitently rendered element.


Because the textbox is readonly; which is the expected behaviour. You can select a file using the Browse button.

Typing is not an option, since the file is on the users pc and the webpage cannot directly access those files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜