您的位置:首页 > Web前端 > JavaScript

JSP显示系统时间

2012-02-23 09:33 211 查看
JSP页面中使用JavaScript获取系统时间,如下代码:

<%@ 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>SysTime - www.cxybl.com</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">
<script language="JavaScript" type="text/javascript">
function showTime(){
var now=new Date;
document.getElementById("dd").innerHTML=now.getFullYear()
+"年"+(now.getMonth()+1)
+"月"+now.getDate()
+"日"+now.getHours()
+":"+now.getMinutes()+":"+now.getSeconds();
setTimeout("showTime()","1000");
}
</script>
</head>
<body onload="showTime()">
<div id=dd></div>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: