遗失的美好 发表于 2007-4-27 11:30:29

***时间日期***按钮控制时间日期转换

把下列代码加到网页的<body></body>标签之间 从google下载我的照片管理软件
脚本说明:
第一步:把如下代码加入<head>区域中
<script language="javascript">
<!-- helpers for jsi page...

// navigation - start

function goback(){


alert("good bye!");

history.go(-1);

}

function getname(str) {

      alert("hi, "+ str+"!");

}

function getthedate() {

stopclock();

todays = new date();

thedate = "" + (todays.getmonth()+ 1) +" / "+ todays.getdate() + " / " +

todays.getyear()

document.clock.face.value = thedate;

}

function showit () {

      var now = new date();

      var hours = now.gethours();

      var minutes = now.getminutes();

      var seconds = now.getseconds();

          stopclock();

          totaltime = (minutes > gettotal)? (minutes-gettotal):totaltime;

      document.clock.face.value = totaltime + " in minutes ";

}

// navigation - stop

// netscapes clock - start

// this code was taken from netscapes javascript documentation at

// www.netscape.com on jan.25.96



var timerid = null;

var totaltime = 0;

var gettotal = 0;

var timerrunning = false;

function stopclock (){

      if(timerrunning)

                cleartimeout(timerid);

      timerrunning = false;

}



function startclock () {

      // make sure the clock is stopped

      var now = new date();

      stopclock();

          gettotal=now.getminutes();

      getthedate()

      showtime();

}

function showtime () {

      var now = new date();

      var hours = now.gethours();

      var minutes = now.getminutes();

      var seconds = now.getseconds()

      var timevalue = "" + ((hours >12) ? hours -12 :hours)

      timevalue += ((minutes < 10) ? ":0" : ":") + minutes

      timevalue += ((seconds < 10) ? ":0" : ":") + seconds

      timevalue += (hours >= 12) ? " p.m." : " a.m."

      document.clock.face.value = timevalue;

      timerid = settimeout("showtime()",1000);

      timerrunning = true;

}

function showtimer () {

      var now = new date();

      var hours = now.gethours();

      var minutes = now.getminutes();

      var seconds = now.getseconds()

      var timevalue = "" + ((hours >12) ? hours -12 :hours)

      timevalue += ((minutes < 10) ? ":0" : ":") + minutes

      timevalue += ((seconds < 10) ? ":0" : ":") + seconds

      timevalue += (hours >= 12) ? " p.m." : " a.m."

          document.clock.tspent.value = timevalue;

      timerid = settimeout("showtime()",1000);

      timerrunning = true;

}

// netscapes clock - stop



// end helpers -->
</script>



第二步:把如下代码加入<body>区域中
<form name="clock" onsubmit="0">
       <input   type=button value="time" size=12 onclick="showtime()">
      <input    type=button value="date" size=12 onclick="getthedate()">
      <input type="text" name="face" size=12 value="" starttimer()>
</form>

第三步:把<body>区中内容改为
<body bgcolor="#fef4d9" onload="startclock()">

      











-------- -- --------------- ------------ -


h ttp://www.huoyue.com.cn 活跃网,活 跃人群的论坛,访问活跃网,将给您带来意想不到的收获,还可以免费为您开论坛,让您免费拥有与朋友、网友交流的论坛。你是年轻人吗?你活跃你就上 !
页: [1]
查看完整版本: ***时间日期***按钮控制时间日期转换