該腳本運行以后將彈出一個提示窗口。
腳本:
<script language="JavaScript">
alert ("Warning!我是JavaScript初學者!");
</script>
另外我本人編寫了一個程序可以自動生成本節(jié)中在線試題的源代碼,下載頁面在“技術支持”一欄中。
<script language="JavaScript">
var MyColor;
MyColor=prompt("您最喜歡的顏色是:","");
switch(MyColor) {
case "紅色":
document.bgColor="red";
break;
case "黃色":
document.bgColor="yellow";
break;
case "灰色":
document.bgColor="gray";
break;
default:
alert("我不認識這些顏色!");
}
</script>
<script language="LiveScript">
today = new Date()
document.write("現(xiàn)在時間是: ",today.getHours(),":",today.getMinutes())
document.write("<br>今天日期為: ", today.getMonth()+1,"/",today.getDate()
,"/",today.getYear());
</script>
<script language="JavaScript">
window.open("time.htm", "日期");
</script>
<html>
<head>
<script language="LiveScript">
function WinOpen() {
window.open("time.htm", "日期");
}
</script>
</head>
<body>
<form>
<input type="button" name="Button1" value="看看時間" onclick="WinOpen()">
</form>
</body>
</html>
<html>
<head>
<script language="JavaScript">
function cal(theForm) {
var score=0;
if (theForm.R1.value =="c") score++;
if (theForm.R2.value =="b") score++;
if (theForm.R3.value =="a") score++;
if (theForm.R4.value =="b") score++;
if (theForm.R5.value =="c") score++;
alert ("你的得分是:"+score*20+"分");
}
</script>
</head>
<body>
<center>
<h1>英語形成性練習題</h1>
</center>
<form name="myForm">
<p><b>單向選擇題,每題20分,共100分</b></p>
You have to ___ your younger brother since mother is not at home. <br>
<input type="radio" name="R1" value="V1" onClick="document.myForm.R1.value='a'"> take care <br>
<input type="radio" name="R1" value="V2" onClick="document.myForm.R1.value='b'"> take after <br>
<input type="radio" name="R1" value="V3" onClick="document.myForm.R1.value='c'"> look after <br>
You have to ___ the registration form in order to use that website. <br>
<input type="radio" name="R2" value="V1" onClick="document.myForm.R2.value='a'"> carry on <br>
<input type="radio" name="R2" value="V2" onClick="document.myForm.R2.value='b'"> fill in <br>
<input type="radio" name="R2" value="V3" onClick="document.myForm.R2.value='c'"> keep up <br>
David, please ___ these books ___ to the libarary. <br>
<input type="radio" name="R3" value="V1" onClick="document.myForm.R3.value='a'"> take / back <br>
<input type="radio" name="R3" value="V2" onClick="document.myForm.R3.value='b'"> take / off <br>
<input type="radio" name="R3" value="V3" onClick="document.myForm.R3.value='c'"> take / out <br>
If it rains, they will have to ___ the picnic. <br>
<input type="radio" name="R4" value="V1" onClick="document.myForm.R4.value='a'"> go through <br>
<input type="radio" name="R4" value="V2" onClick="document.myForm.R4.value='b'"> put off <br>
<input type="radio" name="R4" value="V3" onClick="document.myForm.R4.value='c'"> set off <br>
I like ___ the radio. <br>
<input type="radio" name="R5" value="V1" onClick="document.myForm.R5.value='a'"> listening at <br>
<input type="radio" name="R5" value="V2" onClick="document.myForm.R5.value='b'"> listening for <br>
<input type="radio" name="R5" value="V3" onClick="document.myForm.R5.value='c'"> listening to <br>
<p><input type="button" value="完成" name="B1" onclick="cal(myForm)"></p>
</form>
</body>
</html>