<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js清空FileUpload中的路径</title>
<style>
*{margin:0; padding:0;}
body{font-size:12px; color:#000; text-align:center;}
</style>
</head>
<body>
<input type="file" id="file" />
<input id="btn" type="button" value="clean" />
<input id="show" type="button" value="showDirects" />
<script>
document.getElementById('btn').onclick = function(){
if(document.all){
//IE
document.getElementById('file').select();
document.execCommand('Delete');
document.getElementById('file').blur();
}else{
//FF
document.getElementById('file').value = '';
return false;
}
}
document.getElementById('show').onclick = function(){
alert(document.getElementById('file').value);
}
</script>
</body>
</html>