老兄急,帮忙做几个,在有数字的地方填空!
1,在页面上显示一个底色为大红色、文字为“SCHOOL”的按钮(即图片school-1.gif),当鼠标指向该按钮,变为底色为金黄色、文字为“SCHOOL”的按钮(即图片school-2.gif),单击该按钮,打开一个网站的主页:www.ncu.edu.cn。
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="-----(1)-----">
<!--
function MM_swapImgRestore() {
var i,x,a=document.MM_sr;
for (i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
x.src=x.oSrc;
}
function MM_preloadImages() {
var d=document;
if(d.images)
{ if(!d.MM_p)
d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
for( -----(2)----- =0; i<a.length; i++)
if (a[i].indexOf("#")!=0)
{ d.MM_p[j]=new Image;
d.MM_p[j++].src=a[i];
}
}
}
function MM_findObj(n, d) {
var p,i,x;
if (!d) d=document;
if ((p=n.indexOf("?"))>0&&parent.frames.length)
{ d=parent.frames[n.substring(p+1)].document;
n=n.substring(0,p);
}
if (!(x=d[n])&&d.all)
x=d.all[n];
for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[i][n];
for (i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers[i].document);
return x;
}
function MM_swapImage() {
var i,j=0,x,a=MM_swapImage.arguments;
document.MM_sr=new Array;
for (i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null)
{ document.MM_sr[j++]=x;
if(!x.oSrc) x.oSrc=x.src;
x.src=a[i+2];
}
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" onLoad="MM_preloadImages('image/school-2.gif')">
<a href=" http://www.ncu.edu.cn/" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage(-----(3)-----,'','school-2.gif',1)">
<img name="Image1" border="0" src="school-1.gif" width="162" height="57"></a>
</body>
</html>
2,实现一个倒计时程序,显示当前日期距离2019年12月31日还有多少年、多少月和多少天。请将程序中标明的(1)(2)(3)处补充完整,使它能得出正确的结果。
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var Temp2;
var timerID = null;
var timerRunning = false;
function arry() {
this.length = 12;
this[0] = 31;
this[1] = 28;
this[2] = 31;
this[3] = 30;
this[4] = 31;
this[5] = 30;
this[6] = 31;
this[7] = 31;
this[8] = 30;
this[9] = 31;
this[10] = 30;
this[11] = 31;
}
var date = new arry();
function stopclock() {
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function startclock() {
stopclock();
showtime();
}
function showtime() {
now = new Date();
var CurMonth = now.getMonth();
var CurDate = now.getDate();
var CurYear = now.getFullYear();
now = null;
if (12 < CurDate) {
CurDate -= date[CurMonth]; CurMonth++;
}
if (11 < CurMonth) {
CurMonth -= 12; CurYear++;
}
var Yearleft = (1) - CurYear;
var Monthleft = 12 - CurMonth;
var Dateleft = 31 - CurDate;
document.dateform.a.value = (2);
document.dateform.b.value = Monthleft;
document.dateform.c.value = Dateleft;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
// End -->
</script>
</HEAD>
<body Onload="(3)">
</BODY>
<form name=dateform>距离12/31/2019还有
<input type=text name=a size=2 value="">年
<input type=text name=b size=2 value="">月
<input type=text name=c size=2 value="">天
</form>
</HTML>
3,在页面上提示输入数字,假设输入数字“5”,则页面显示:“恭喜你,中奖了!”;否则页面显示“非常遗憾,欢迎下次再玩!”。
<html>
<head>
<title>幸运者游戏-----(1)-----
<script language="Javascript">
<!--
function luckynumber()
{
yournumber=prompt("请从1--10中选择一个数字:",1);
while (!confirm("你确认选择"+yournumber+"吗?"))
{
yournumber=prompt("请从1--10中选择一个数字:",1);
}
if (-----(2)-----)
{
alert("恭喜你,中奖了!");
}
else
{
alert("非常遗憾,欢迎下次再玩!");
}
}
----(3)------
4,在页面上显示系统时间,假设系统时间为:2005年12月5日上午10时50分29秒,则在页面上显示:“现在是:2005年12月5日10:50:29 AM ”。
<html>
<head>
-----(1)-----
<!--
function show(){
var Digital=new Date()
var year=Digital.getYear()
var month=Digital.getMonth()
var day=Digital.getDay()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=-----(2)-----
var dn="AM"
if(hours>12)
{
dn="PM"
hours=hours-12
}
if(hours==0)
hours=12
if(minutes<=9)
minutes="0"+minutes
if(seconds<=9)
seconds="0"+seconds
myclock="<font>现在是:</font>"+year+"年"+month+"月"+day+"日"+hours+":"+minutes+":"+seconds+" "+dn+" "
if(document.layers)
{
document.layers.liveclock.document.write(myclock)
document.layers.liveclock.document.close()
}else if(document.all)
liveclock.innerHTML=myclock
setTimeout("show()",1000)
}
//>
</SCRIPT>
-----(3)-----
<body bgcolor="#fef4d9" ONLOAD=show()>
<span id=liveclock style=position:absolute;left:50;top:22;width: 119; height: 15>
</span>
</body>
</html>
5,将255以内的十进制数转换成十六进制数,
如输入100,显示结果为64。请将程序中标明的(1)(2)(3)处补充完整,使它能得出正确的结果。
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></HEAD>
<SCRIPT Language="javascript">
// 十进制转换为十六进制数
function dechex(cval){
if (cval >255) {cval = 255};
hexascii = "0123456789ABCDEF";
cval0 = Math.floor(cval/16);
cval1 = cval - (cval0 * 16);
c1 = hexascii.charAt(cval0);
c2 = hexascii.charAt(cval1);
mystr = c1 + c2;
return ---(1)---;
}
// 显示结果
function DoDecHex(){
myfield = document.forms['convert'].elements['Dec'].value;
---(2)---= dechex(myfield);
alert ('结果是: ' + myval);
}
</SCRIPT>
<BODY>
<FORM NAME="convert">
255以内的十进制数转换成十六进制数:<BR>
十进制数:
<INPUT TYPE="Text" SIZE="10" NAME="Dec">
<INPUT TYPE="Button" VALUE="change" onClick="---(3)---"><BR>
<BR>
<BR>
</BODY>
</HTML>