本随笔缩写内容有误,对不起,谢谢!
csdn上有朋友问道这个问题
上google跑了跑,从这里和csdn的980337(面包喳喳) 朋友的回复得到提示,做了做测试。
以下代码可以把“浏览”按钮换成图片
当然 也可以不用<img>而改input或者button加上样式表(css)或者htc也应该可以吧。
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
< html xmlns ="http://www.w3.org/1999/xhtml" xml:lang ="gb2312" lang ="gb2312" >
< head >
< title > 上传的时候 < input type ="file" > 中用图片代替浏览按钮 </ title >
< meta http-equiv ="Content-Type" content ="text/html; charset=gb2312" />
< meta name ="title" content ="" />
< meta name ="author" content ="活靶子,huobazi" />
< meta name ="subject" content ="" />
< meta name ="language" content ="gb2312" />
< meta name ="keywords" content ="" />
< meta name ="Copyright" content ="" />
< meta name ="robots" content ="all" />
< script language ="javascript" type ="text/javascript" >
function fn_browse()
{
document.test_form.browse.click();
document.test_form.file.value = document.all.test_form.browse.value;
}
</ script >
</ head >
< body >
< form name ="test_form" method ="post" ENCTYPE ="multipart/form-data" onsubmit ="alert(document.test_form.browse.value);" />
< input type ="file" name ="browse" style ="display:none;" />
< input type ="text" name ="file" />
< a href ="javascript:fn_browse();" >
< img name ="btn" src ="browse.gif" border ="0" />
< br />
< br />
< input type ="submit" name ="提交表单" />
</ form >
</ body >
</ html >
< html xmlns ="http://www.w3.org/1999/xhtml" xml:lang ="gb2312" lang ="gb2312" >
< head >
< title > 上传的时候 < input type ="file" > 中用图片代替浏览按钮 </ title >
< meta http-equiv ="Content-Type" content ="text/html; charset=gb2312" />
< meta name ="title" content ="" />
< meta name ="author" content ="活靶子,huobazi" />
< meta name ="subject" content ="" />
< meta name ="language" content ="gb2312" />
< meta name ="keywords" content ="" />
< meta name ="Copyright" content ="" />
< meta name ="robots" content ="all" />
< script language ="javascript" type ="text/javascript" >
function fn_browse()
{
document.test_form.browse.click();
document.test_form.file.value = document.all.test_form.browse.value;
}
</ script >
</ head >
< body >
< form name ="test_form" method ="post" ENCTYPE ="multipart/form-data" onsubmit ="alert(document.test_form.browse.value);" />
< input type ="file" name ="browse" style ="display:none;" />
< input type ="text" name ="file" />
< a href ="javascript:fn_browse();" >
< img name ="btn" src ="browse.gif" border ="0" />
< br />
< br />
< input type ="submit" name ="提交表单" />
</ form >
</ body >
</ html >