javascript练习输出某天是星期几

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>webrx-title</title>
<script type="text/javascript">
 function toDate(uYear, uMonth, uDay) {
 //定义一个函数,且有三个变量
var arr = "日一二三四五六".split("");
with(document.all) {
var vYear = parseInt(uYear, 10);
var vMonth = parseInt(uMonth, 10);
var vDay = parseInt(uDay, 10);
}
var date = "星期"+arr[new Date(vYear,vMonth-1,vDay).getDay()];
               document.write("刚才输入的日期是:"+date);
// alert(date);


return  date;
 }


window.onload = function() {
var dateStr = prompt("请输入年月日(注意格式如:2014-07-23)")
// var dateStr = "2010-07-01";
var arr = dateStr.split("-");
toDate(arr[0], arr[1], arr[2]);
}
 
</script>
</head>


<body>
</body>
</html>

你可能感兴趣的:(javascript练习输出某天是星期几)