<html>
<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 rx, rx1, rx2, maxNum, minNum;
minNum=0;
maxNum=9;
rx=Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
rx1=Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
rx2=Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
while(rx1==rx || rx1==rx2){
rx1=Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
}
while(rx2==rx || rx2==rx1){
rx2=Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
}
document.write("亂數"+rx+rx1+rx2);
</Script>
</body>
</html>
沒有留言:
張貼留言