更改上传文件的样式<input type="file>
来源:互联网 发布:淘宝处罚考试虚假交易 编辑:程序博客网 时间:2024/05/18 00:21
很多人肯定都遇到过关于那个样式只有个浏览按钮的那个上传控件了吧,我也不喜欢啊,因为项目不允许它长那难看,好吧,我采用Js把它巧妙的隐藏伪装了一下,变成了下面的样式,你看还可以不,嘻嘻
浏览就变成了从目录中选择,大家看到的那个文本框其实也不是原有的那个了呢,请看代码吧
这是那个表单
<div class="si_form"> <dl> <dt style="margin-bottom:10px;">客户端设置</dt> <form action="upload" method="post" enctype="MULTIPART/FORM-DATA" > <table width="100%" border="0" cellspacing="0" cellpadding="0" class="si_app"> <tr> <td width="9%"><img src="../static/images/u59.png" width="44" height="40" /></td> <td width="16%" align="center">Windows版</td> <td><div class="app_bor" id="div_Test">ghfgjfhjf</div></td> <td align="left"><div class="file-box"> <input type='button' class="app_btn" value='从目录中选择' /> <input type="file" name="windows" class="app_file" id="fileField" size="28" onchange="showText(this)" /> </div> </td> </tr> <tr> <td><img src="../static/images/u63.png" width="44" height="47" /></td> <td align="center">Android</td> <td><div class="app_bor" id="div_Test1">ghfgjfhjf</div></td> <td align="left"><div class="file-box"> <input type='button' class="app_btn" value='从目录中选择' /> <input type="file" name="Android" class="app_file" id="fileField1" size="28" onchange="showText1(this)" /> </div> </td> </tr> <tr> <td><img src="../static/images/u61.png" width="48" height="47" /></td> <td align="center">Mac版</td> <td><div class="app_bor" id="div_Test2">ghfgjfhjf</div></td> <td align="left"><div class="file-box"> <input type='button' class="app_btn" value='从目录中选择' /> <input type="file" name="Mac" class="app_file" id="fileField2" size="28" onchange="showText2(this)" /> </div> </td> </tr> </table> </dl> <div class="form_but"><input type="submit" value="保存设置"/></div> </form> </div>下面是JS
<SCRIPT LANGUAGE="JavaScript"><!--function reAsk(sStr){ return confirm(sStr);}function getFileName(o){ var pos=o.value.lastIndexOf("\\"); return o.value.substring(pos+1);//文件名 }function GetFileExt(o){ return o.value.replace(/.+\./,"");}function showText(o){document.getElementById("div_Test").innerHTML=o.value.substring(o.value.lastIndexOf("\\")+1);}function showText1(o){document.getElementById("div_Test1").innerHTML=o.value.substring(o.value.lastIndexOf("\\")+1);}function showText2(o){document.getElementById("div_Test2").innerHTML=o.value.substring(o.value.lastIndexOf("\\")+1);}function openBrowse(){ var ie=navigator.appName=="Microsoft Internet Explorer" ? true : false; if(ie){ document.getElementById("file").click(); document.getElementById("filename").value=document.getElementById("file").value;}else{var a=document.createEvent("MouseEvents");//FF的处理 a.initEvent("click", true, true); document.getElementById("file").dispatchEvent(a); } } //--></SCRIPT>
好吧,就这样了,还有Css设置,大家自己弄弄吧
0 0
- 更改上传文件的样式<input type="file>
- 自定义 input type="file" 文件上传样式
- 上传文件控制input type="file"样式修改记
- 上传按钮<input type='file'/>的样式美化
- css input[type=file] 样式美化(input上传文件样式 )
- 美化文件域input type=file的样式
- input[type=file] 样式美化,input上传按钮美化
- 使用input type="file"上传文件
- input type=file 服务器端上传文件
- <input type="file"/> 文件上传
- 浏览选择上传文件的控件 input type=file
- input type="file" 样式的模仿
- input[type="file"]的样式修改
- 自定义input[type=”file”]的样式
- input,type="file"的样式修改
- 美化input type="file"的样式
- <input type="file">更改 页面显示 浏览 为上传 .
- HTML上传文件样式type="file"
- 数论整理
- uva 11404 Palindromic Subsequence (dp+字典序最小路径)
- Linux环境下GNU, GCC, G++编译器
- Spring--开篇
- solrconfig.xml配置详解
- 更改上传文件的样式<input type="file>
- plsql 格式化sql 语句
- c写php扩展传参学习记录
- 没胆听意见就别谈论文发表
- Eclipse设置自动提示
- 重装系统后的QQ聊天记录恢复方法与教程
- json配置
- Java中值传递和引用传递问题
- 关于《C#入门经典》的读后总结