首页 > 代码库 > JavaScript - 对象专用语句[ with语句 ]

JavaScript - 对象专用语句[ with语句 ]

<html>

	<head>
		
	<head>

	<body>
		<script language="javascript">
		// 对象专用语句
		// with语句
		/*
		 *	with(对象名称){
		 *		执行语句块
		 *	}
		 */
			var current_time = new Date();
			with(current_time){
				var strDate = getYear() + "年" ;
				strDate += (getMonth() + 1) + "月" ;
				strDate += getDate() + "日" ;
				strDate += getHours() + ":" ;
				strDate += getMinutes() + ":" ;
				strDate += getSeconds() ;
				alert(strDate) ;	
			}			
		</script>
	</body>

</html>

JavaScript - 对象专用语句[ with语句 ]