file 元素样式的模拟(兼容模式)

<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">   <span style="position:relative">input type="button" οnmοuseοver="fclick(t_file)" value="选择上传文件">

<input name="upload" type="file" style="position:absolute;filter:alpha(opacity=30);opacity:0;width:30px;" id="t_file" οnchange="f_file.value=this.value" size="9" hidefocus>
</span>
<br><input type="submit" value="提交">

</form>


 html中file格式的宽度在IE下面可以用width来定义,但在firefox下面却要用size来定义其宽度
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值