JS 在前台判断文件大小

<html>
<title>aa</title>
<script type="text/javascript">    
function getFileSize(obj) {
    var size = 0;
	if(navigator.userAgent.indexOf("MSIE")>0){  
		var fso = new ActiveXObject('Scripting.FileSystemObject');
		var file = fso.GetFile(obj.value);
		size = file.size; 
	}else {
		size = obj.files[0].size;
	}
	alert(size);
}  
 
</script>    
<body>    
<INPUT TYPE="file" NAME="file" SIZE="30" onchange="getFileSize(this)">  

<form>
	<input type="text"/>
	<select>
		<option>ddd</option>
		<option>ccc</option>
	</select>
	<a href="#C">aa</a>

	<a name="C">aaddddddddddd</a>
</form>
<script type="text/javascript">    
	document.cookie = "name=aaa"; 
	alert(document.cookie);

	var reg = new RegExp("\\d+", "i");
	alert(reg instanceof Object);
	alert(reg.test("123"));
	alert(/\d+/.test("123"));
</script>    
</body>
</html>


你可能感兴趣的:(function,object,File,input)