Change the style of the file field to realize the same time compatible with IE, firefox_javascript skills

Source: Internet
Author: User
Copy Code code as follows:

<body>
<input type=file id= "J" onchange= "GetValue ();" Style= "-moz-opacity:0;filter:alpha (opacity=0); opacity:0;position : absolute;left:166px; "/>
<input id= "Ye" style= "color:green;border:1px solid green;width:300px;"/>
<input type= "button" value= "File" style= "border:1px solid;" green;width:80px
</body>

<script language= "JavaScript" >
function GetValue () {
document.getElementById (' ye '). Value = document.getElementById (' j '). Value;
}
</script>

Ideas:

1, the stubborn file domain is <input type=file/> Transparency: style= "-moz-opacity:0;filter:alpha (opacity=0); opacity:0;"

2, with a text box and buttons in place of the file and the appearance

3. Put the browse button of the file field above the button we wrote

4, use JS to get the value of the file field change is: The resulting file path, and assigned to the text box value, so OK

I am just experimenting, the style is very simple, actually can further beautify;

The advantage of this is that it simply simulates the appearance of the file field, which is actually working with file field files, which is convenient.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.