Using transparent stack addition to beautify the file upload interface is estimated that many people are helpless about the ugly style of the file domain. For a perfect web system, this interface is unacceptable. Gmail attachments are added to IE browsers to implement style customization, which makes everyone very excited. They use the click () method of the file domain, but the client's security restrictions are extremely demanding, only iframe can be used together, and the code is more complex. I am using transparent stack addition, that is, place the file domain on the top of the click target and make it transparent. In this way, the user can see the custom hot zone and click the Browse button, no violation of any security mechanism. Similarly, this method also supports firefox.
<Style> * {font-size: 12px; cursor: default }. hand {cursor: hand; cursor: pointer} </style> <body> </body> script file_create () function file_create () {$ ("bxAtt2 "). innerHTML = "<input onchange = file_change (this) hidefocus type = file name = file1 size = 1 class = hand>"} function file_change (tx) {var sName, o sName = tx. value. replace (// \/g ,"/"). replace (/(. *\/)(. *)/, "$2") o = document. createElement ("nobr") o.style.css Te Xt = "float: left; margin-right: 6; padding-top: 3; color: darkgreen" o. innerHTML = "□" + sName +" "+ unescape (" × ") +" "tx. style. display = "none" o. appendChild (tx) $ ("bxAttList "). insertBefore (o, $ ("bxAtt") file_repos () file_create ()} function file_repos () {$ ("bxAttList "). appendChild ($ ("bxAtt")} function $ (obj) {return typeof (obj) = "object "? Obj: document. getElementById (obj)} script
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]