使用透明叠加法美化文件上传界面
2007-03-12 15:08
537 查看
估计很多人都对文件域那难看的样式无可奈何,对于一个讲究完美的web系统来说,这种界面是无法接受的。gmail的附件添加在IE浏览器中实现了样式自定义,让大伙兴奋了好一这,他使用的是文件域的click()方法,但客户端的安全限制非常苛刻,必须结合iframe才能实现,代码比较繁锁。我使用的是透明叠加法,即把文件域置于点击目标之上,并让其透明,这样用户看到的是自定义热区,点击的依然是浏览按钮,没有违反任何安全机制。同样地,这种方法也支持firefox。
◇ 测试程序 - >> 运行下面的js[/u] |
<style> *{font-size:12px;cursor:default} .hand{cursor:hand;cursor:pointer} </style> <body> <form name=fm1> <div id=bxAttList> <div id=bxAtt onmouseover="$('bxAtt1').style.textDecoration='underline'" onmouseout="$('bxAtt1').style.textDecoration=''" style=float:left;width:60> <span id=bxAtt1 style='position:absolute;padding-top:3;cursor:hand;font-family:宋体'>@添加附件</span> <span id=bxAtt2 onmouseover=this.scrollLeft=100 style=position:absolute;width:60;overflow:hidden;filter:alpha(opacity=0);-moz-opacity:0></span> </div> </div> </form> </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.cssText="float:left;margin-right:6;padding-top:3;color:darkgreen" o.innerHTML="□"+sName+"<font onclick=$('bxAttList').removeChild(this.parentNode);file_repos() class=hand style=color:red;font-weight:bold>"+unescape("×")+"</font>" 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> |
相关文章推荐
- 使用透明叠加法美化文件上传界面的代码
- 使用透明叠加法美化文件上传界面 (http://cms.bmw.net.cn)
- 使用透明叠加法美化文件上传界面
- 使用透明叠加法美化文件上传界面 (http://www.script8.com/bbs/thread.asp?tid=6)
- 使用透明叠加法美化文件上传界面
- 使用透明叠加法美化文件上传界面的代码
- 使用透明效果来自定义文件上传按钮控件样式
- [导入]使用Flash打造可定义界面风格的文件上传控件
- 使用 jquery 的 上传文件插件 uploadify 3.1 配合 java 来做一个简单的文件上次功能。并且在界面上有radio 的选择内容也要上传
- 使用Flash打造可定义界面风格的文件上传控件
- 使用 jquery 的 上传文件插件 uploadify 3.1 配合 java 来做一个简单的文件上次功能。并且在界面上有radio 的选择内容也要上传
- 使用透明效果来自定义文件上传按钮控件样式
- HDFS设计思路,HDFS使用,查看集群状态,HDFS,HDFS上传文件,HDFS下载文件,yarn web管理界面信息查看,运行一个mapreduce程序,mapreduce的demo
- input[type=file] 样式美化,input上传按钮美化,使用ajax上传无须控件上传文件
- HDFS设计思路,HDFS使用,查看集群状态,HDFS,HDFS上传文件,HDFS下载文件,yarn web管理界面信息查看,运行一个mapreduce程序,mapreduce的demo
- 使用HttpClient实现文件的上传下载
- Using a MultipartResolver with Commons FileUpload[就是使用commons FileUpload上传文件]
- 使用SpringMVC完成文件上传
- AEAI Miscdp文件上传功能使用心得
- 利用SecureCRT上传、下载文件(使用sz与rz命令)