11、倒计时载入页面

11、倒计时载入页面

脚本说明:

第一步:把如下代码加入<head>区域中:

 <META HTTP-EQUIV="REFRESH" CONTENT="11; URL=14.htm">

 

 

第二步:<body>中加入如下代码:

 <META HTTP-EQUIV="REFRESH" CONTENT="11; URL=14.htm">

 

 <script language="JavaScript">

 

 startday = new Date();

 clockStart = startday.getTime();

 

 function initStopwatch()

 {

  var myTime = new Date();

         var timeNow = myTime.getTime(); 

         var timeDiff = timeNow - clockStart;

         this.diffSecs = timeDiff/1000;

         return(this.diffSecs);

 }

 

 function getSecs()

 {

         var mySecs = initStopwatch();

         var mySecs1 = ""+mySecs;

         mySecs1= mySecs1.substring(0,mySecs1.indexOf(".")) + " secs.";

         document.form1.timespent.value = mySecs1

         window.setTimeout('getSecs()',1000);

 }

 

 

 </script>

 

 

  <center>

 This page will change in 10 seconds:

 <form name=form1><input size=9 name=timespent></form>

 </center>

 

 

第三步:把<body>中内容改为:

<body bgcolor="#fef4d9" onLoad="window.setTimeout('getSecs()',1)">

 

Write a comment

Comments: 0