<script>
function fclick(obj){
with(obj){
style.posTop=event.srcElement.offsetTop
var x=event.x-offsetWidth/2
if(x<event.srcElement.offsetLeft)x=event.srcElement.offsetLeft
if(x>event.srcElement.offsetLeft+event.srcElement.offsetWidth-offsetWidth)x=event.srcElement.offsetLeft+event.srcElement.offsetWidth-offsetWidth
style.posLeft=x
}
}
</script>
<style>
input{border:1px solid #333333;color:#666666;background:#eeeeee;font:normal 12px Tahoma;height:18px}
</style>
<form method="post" action="" enctype="multipart/form-data">
<input id="f_file"> <input type="button" onmouseover="fclick(t_file)" value="选择上传文件">
<input name="upload" type="file" style="position:absolute;filter:alpha(opacity=0);width:30px;" id="t_file" onchange="f_file.value=this.value" hidefocus>
<br><input type="submit" value="提交">
</form>
修改上传文件选择框样式[转]
文件上传组件实现
最新推荐文章于 2025-10-15 15:35:47 发布
本文介绍了一个简单的文件上传组件实现方式,通过HTML和JavaScript技术实现了文件选择与提交的功能。该组件使用了绝对定位和透明度设置来达到隐藏实际文件输入框的效果,同时通过按钮触发文件选择对话框。
2140

被折叠的 条评论
为什么被折叠?



