1.
1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2 pageEncoding="UTF-8"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 4 <html> 5 <head> 6 <title>标题页</title> 7 <META HTTP-EQUIV="REFRESH" CONTENT="11; URL=http://www.google.com"> 8 <script language="JavaScript"> 9 //获取当前时间 10 startday = new Date(); 11 clockStart = startday.getTime(); 12 13 function initStopwatch() 14 { 15 var myTime = new Date(); 16 var timeNow = myTime.getTime(); 17 var timeDiff = timeNow - clockStart; //获取间隔时间 18 this.diffSecs = timeDiff/1000; //因为时间以毫秒为单位 19 return(this.diffSecs); //返回间隔秒数 20 } 21 function getSecs() 22 { 23 //获取调用方法时间-当前时间的时间 24 var mySecs = initStopwatch(); 25 var mySecs1 = ""+mySecs; 26 //以倒计时方式显示时间 27 mySecs1= 10 - eval(mySecs1.substring(0,mySecs1.indexOf("."))) + "秒"; 28 document.form1.timespent.value = mySecs1; 29 window.setTimeout('getSecs()',1000); 30 } 31 </script> 32 </head> 33 <body bgcolor="#ffffff" onLoad="window.setTimeout('getSecs()',1)"> 34 <center> 35 10秒后将加载页面: 36 <form name=form1><input size=9 name=timespent></form> 37 </center> 38 </body> 39 </html>