随机点名程序
document.write(Math.random());
var stu = ["张三", "王五", "张二", "张一", "石大", "郭三", "冯二", "平五"];
var ran = Math.random();
var ran = ran * stu.length;
var ran = Math.floor(ran);
document.write(stu[ran]);
万年历
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="time"></div>
</body>
</html>
<script>
function wnl() {
var time = new Date();
var year = time.getFullYear();
var month = time.getMonth() + 1;
var day = time.getDate();
var hour = time.getHours();
if (hour<10){
hour1=hour;
hour="0"+hour1;
}
var min = time.getMinutes();
if (min<10){
min1=min;
min="0"+min1;
}
var sec = time.getSeconds();
if (sec<10){
sec1=sec;
sec="0"+sec1;
}
var time_str = year + "年" +
month + "月" +
day + "日" +
" " +
hour + ":" +
min + ":" +
sec;
document.getElementById("time").innerHTML =
time_str;
}
var x = window.setInterval("wnl()", 500);
</script>