JavaScript从入门到精通程序练习帖子-P92 2006年4月5日
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="JavaScript" type="text/javascript">
function showResults()
{
var resultMsg="" //数组方式读取控件名称
if(document.survey.age[0].checked) resultMsg+="under 30"
if(document.survey.age[1].checked) resultMsg+="between 30 and 60"
if(document.survey.age[2].checked) resultMsg+="over 60"
if(document.survey.sex[0].checked) resultMsg+="male"
if(document.survey.sex[1].checked) resultMsg+="female"
if(document.survey.reading.checked) resultMsg+="reading"
if(document.survey.eating.checked) resultMsg+="eating"
if(document.survey.sleeping.checked) resultMsg+="sleeping"
document.survey.results.value=resultMsg //赋值给text
}
function upperCaseResults()
{ //转化成大写
var newResults = document.survey.results.value
document.survey.results.value = newResults.toUpperCase()
}
</script>
</head>
<body bgcolor="#FFFFFF">
<form name="survey" id="survey">
Age:
<input type="radio" name="age" onclick="showResults()" />
under 30
<input type="radio" name="age" onclick="showResults()" />
between 30 and 60
<input type="radio" name="age" onclick="showResults()" />
over 60
<p> Sex:
<input type="radio" name="sex" onclick="showResults()" />
Male
<input type="radio" name="sex" onclick="showResults()" />
Female </p>
<p> Interests:
<input type="checkbox" name="reading" onclick="showResults()" />
Reading
<input type="checkbox" name="eating" onclick="showResults()"/>
Eating
<input type="checkbox" name="sleeping" onclick="showResults()"/>
Sleeping </p>
<p>
<input type="button" name="MakeUpper" value="ToUpperCase" onclick="upperCaseResults()"/>
<input type="text" name="results" size="50" />
<input type="submit" name="submit" value="submit" onclick='return confirm("sure")' />
<input type="reset" name="reset" onclick='return confirm("Sure")' />
</p>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="JavaScript" type="text/javascript">
function showResults()
{
var resultMsg="" //数组方式读取控件名称
if(document.survey.age[0].checked) resultMsg+="under 30"
if(document.survey.age[1].checked) resultMsg+="between 30 and 60"
if(document.survey.age[2].checked) resultMsg+="over 60"
if(document.survey.sex[0].checked) resultMsg+="male"
if(document.survey.sex[1].checked) resultMsg+="female"
if(document.survey.reading.checked) resultMsg+="reading"
if(document.survey.eating.checked) resultMsg+="eating"
if(document.survey.sleeping.checked) resultMsg+="sleeping"
document.survey.results.value=resultMsg //赋值给text
}
function upperCaseResults()
{ //转化成大写
var newResults = document.survey.results.value
document.survey.results.value = newResults.toUpperCase()
}
</script>
</head>
<body bgcolor="#FFFFFF">
<form name="survey" id="survey">
Age:
<input type="radio" name="age" onclick="showResults()" />
under 30
<input type="radio" name="age" onclick="showResults()" />
between 30 and 60
<input type="radio" name="age" onclick="showResults()" />
over 60
<p> Sex:
<input type="radio" name="sex" onclick="showResults()" />
Male
<input type="radio" name="sex" onclick="showResults()" />
Female </p>
<p> Interests:
<input type="checkbox" name="reading" onclick="showResults()" />
Reading
<input type="checkbox" name="eating" onclick="showResults()"/>
Eating
<input type="checkbox" name="sleeping" onclick="showResults()"/>
Sleeping </p>
<p>
<input type="button" name="MakeUpper" value="ToUpperCase" onclick="upperCaseResults()"/>
<input type="text" name="results" size="50" />
<input type="submit" name="submit" value="submit" onclick='return confirm("sure")' />
<input type="reset" name="reset" onclick='return confirm("Sure")' />
</p>
</form>
</body>
</html>
JavaScript从入门到精通程序练习帖子-P134 2006年4月10日
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function setTimer()
{
timer=window.setTimeout("alert('Too slow!')",1000)
}
function clearTimer()
{
clearTimer(timer) //堆寨溢出在第13行
alert("Congradulations!")
}
</script>
</head>
<body onload="setTimer()">
<form>
<input type="button" value="点击" onclick="clearTimer()" />
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function setTimer()
{
timer=window.setTimeout("alert('Too slow!')",1000)
}
function clearTimer()
{
clearTimer(timer) //堆寨溢出在第13行
alert("Congradulations!")
}
</script>
</head>
<body onload="setTimer()">
<form>
<input type="button" value="点击" onclick="clearTimer()" />
</form>
</body>
</html>
JavaScript从入门到精通程序练习帖子-P145 2006年4月14日13:29:26
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language="javascript">
function createSummary()
{
win2 = open("","window2") //弹出窗口
win2.document.open("text/plain")
win2.document.writeln("Links:"+document.links.length) //输出页面连接的数量
win2.document.writeln("Anchors:"+document.anchors.length)
win2.document.writeln("Forms:"+document.forms.length) //输出页面表单的数量
win2.document.writeln("Images:"+document.applets.length)
win2.document.writeln("Embeds:"+document.embeds.length)
//Embeds 物件是一個陣列, 它代表著所有在 document 內用 <embed> 標記寫成的元件, <embed> 最常用來在網頁播放音樂和電影。
win2.document.close
}
</script>
<body>
<a name="#top"></a>
<p><a href="http;//www.jaworski.com/javascript"></a>
<a href="http://www.sybex.com/"></a>
<form>
<input type="button" name="help" value="help" onclick="alert('Click one')"
</form>
<script language="javascript">
setTimeout("createSummary()",5000) //延时5秒后在执行函数
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language="javascript">
function createSummary()
{
win2 = open("","window2") //弹出窗口
win2.document.open("text/plain")
win2.document.writeln("Links:"+document.links.length) //输出页面连接的数量
win2.document.writeln("Anchors:"+document.anchors.length)
win2.document.writeln("Forms:"+document.forms.length) //输出页面表单的数量
win2.document.writeln("Images:"+document.applets.length)
win2.document.writeln("Embeds:"+document.embeds.length)
//Embeds 物件是一個陣列, 它代表著所有在 document 內用 <embed> 標記寫成的元件, <embed> 最常用來在網頁播放音樂和電影。
win2.document.close
}
</script>
<body>
<a name="#top"></a>
<p><a href="http;//www.jaworski.com/javascript"></a>
<a href="http://www.sybex.com/"></a>
<form>
<input type="button" name="help" value="help" onclick="alert('Click one')"
</form>
<script language="javascript">
setTimeout("createSummary()",5000) //延时5秒后在执行函数
</script>
</body>
</html>