<html>
<meta charset = "UTF-8">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<title>第一支javaScript</title>
</head>
<body>
<h2>document.write用法</h2>
<Script type ="text/javascript">
var a,b,c, maxNum, minNum;
minNum=0;
maxNum=9;
a=Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
b=Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
c=Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
while(b==a){
b=Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
}
while(c==a || c == b){
c=Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
}
document.write("亂數"+a+b+c);
</Script>
沒有留言:
張貼留言