<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'MyJsp.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <script type="text/javascript"> function bodyLoad(){ var dateTime=new Date(); var hh=dateTime.getHours();//小时 var mm=dateTime.getMinutes();//分钟 var ss=dateTime.getSeconds();//秒钟 var yy=dateTime.getFullYear();//年份 var MM=dateTime.getMonth()+1; //月份-因为1月这个方法返回为0,所以加1 var dd=dateTime.getDate();//日数 var week=dateTime.getDay();//周(0~6,0表示星期日) var days=[ "日 ", "一 ", "二 ", "三 ", "四 ", "五 ", "六 ",] document.getElementById("date").innerHTML=yy+"年"+MM+"月"+dd+"日 "+"星期"+days[week] ; document.getElementById("time").innerHTML=hh+"时"+mm+"分"+ss+"秒"; setTimeout(bodyLoad,1000); } </script> </head> <body onload="bodyLoad()"> <span id="date" ></span> <span id="time" ></span> </body> </html>
javascript jsp页面动态显示系统时间 测试可用 多浏览器通过测试 (1)
原文地址:http://blog.csdn.net/responsecool/article/details/39291317