<!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"><!--和XHTML兼容-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head>
<body>
<input type="text" name="file1" value="" id="file1" οnkeydοwn="return false;" οncοntextmenu="return false;" οndragenter="return false;" οnpaste="return false;">
<input type="file" name="file2" id="file2" style="display:none" οnchange='document.getElementById("file1").value=this.value'>
<input type="button" value="浏览..." οnclick='document.getElementById("file2").click()'>
</body>
<script language="javascript">
function showMessage(){
alert('message');
return false;
}
</script>
</html>
本质的意思就是说使用一个看不见的file对象,用text框来显示他们的路径,用button来控制file的点击事件,通过修改text框和button的样式来美化file
<html xmlns="http://www.w3.org/1999/xhtml"><!--和XHTML兼容-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head>
<body>
<input type="text" name="file1" value="" id="file1" οnkeydοwn="return false;" οncοntextmenu="return false;" οndragenter="return false;" οnpaste="return false;">
<input type="file" name="file2" id="file2" style="display:none" οnchange='document.getElementById("file1").value=this.value'>
<input type="button" value="浏览..." οnclick='document.getElementById("file2").click()'>
</body>
<script language="javascript">
function showMessage(){
alert('message');
return false;
}
</script>
</html>
本质的意思就是说使用一个看不见的file对象,用text框来显示他们的路径,用button来控制file的点击事件,通过修改text框和button的样式来美化file