自己写了一个显示时间的javascript函数,单独在html页面测试可以,现在想在jsp页面显示,该怎么弄 10
<%@pagecontentType="text/html;charset=GB2312"%><%@tagliburi="http://java.sun.com/jstl...
<%@ page contentType="text/html; charset=GB2312" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ include file="common_process.jsp" %>
<%@ page language="java"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>系统</title>
<script language="javascript" type="text/javascript" id="showTimer">
var today = new Date();
var yy = today.getYear();
if(yy<1900) yy = yy+1900;
var MM = today.getMonth()+1;
if(MM<10) MM='0'+MM;
var dd = today.getDate();
if(dd<10) dd = '0'+dd;
var hh = today.getHours();
var mm = today.getMinutes();
var ss = today.getSeconds();
var SloginDate = yy+"/"+MM+"/"+dd;
var Sseconds = ss;
var Sminutes = mm;
var Shours = hh;
var Sampm;
if(Sseconds>59){
Sseconds=0;
Sminutes++;
if(Sminutes>59){
Sminutes=0;
Shours++;
if(Shours>23) Shours=0;
}
}
ie4=(document.all)?true:false;
function b1(Itime){
if(Itime<10) Itime = '0'+Itime;
return Itime;
}
function writeT(){
Sseconds++;
STimev='';
if(Sseconds>59){
Sseconds=0;
Sminutes++;
if(Sminutes>59){
Sminutes=0;
Shours++;
if(Shours>23) Shours=0;
}
}
if(Shours<12){
Sampm="AM";
}else{
Sampm="PM";
}
STimev+=b1(Shours)+":"+b1(Sminutes)+":"+b1(Sseconds)+" "+Sampm;
if(ie4){
document.all['time'].innerHTML = " Time:"+SloginDate+" "+STimev;
setTimeout('writeT()',1000);
}
}
function test(){
var today = new Date();
var yy = today.getYear();
if(yy<1900) yy = yy+1900;
document.all['test'].innerHTML = "2003 - "+yy+"Copyright";
}
</script>
</head>
<body onload="writeT()" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="56" bgcolor="#007A5E"> </td>
<td width="100%">
<table width="100%" style="background:url(images/top_bg.jpg)" border="0" cellspacing="0" cellpadding="0">
<tr height="70">
<td align="right"><img src="images/log.jpg"/> </td>
<td width="500"><img src="images/font.png" width="500px"/></td>
<td width="700"> </td>
<td width="300">当前时间:
<script language="javascript">writeT();</script>
</td>
</tr>
</table> 展开
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ include file="common_process.jsp" %>
<%@ page language="java"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>系统</title>
<script language="javascript" type="text/javascript" id="showTimer">
var today = new Date();
var yy = today.getYear();
if(yy<1900) yy = yy+1900;
var MM = today.getMonth()+1;
if(MM<10) MM='0'+MM;
var dd = today.getDate();
if(dd<10) dd = '0'+dd;
var hh = today.getHours();
var mm = today.getMinutes();
var ss = today.getSeconds();
var SloginDate = yy+"/"+MM+"/"+dd;
var Sseconds = ss;
var Sminutes = mm;
var Shours = hh;
var Sampm;
if(Sseconds>59){
Sseconds=0;
Sminutes++;
if(Sminutes>59){
Sminutes=0;
Shours++;
if(Shours>23) Shours=0;
}
}
ie4=(document.all)?true:false;
function b1(Itime){
if(Itime<10) Itime = '0'+Itime;
return Itime;
}
function writeT(){
Sseconds++;
STimev='';
if(Sseconds>59){
Sseconds=0;
Sminutes++;
if(Sminutes>59){
Sminutes=0;
Shours++;
if(Shours>23) Shours=0;
}
}
if(Shours<12){
Sampm="AM";
}else{
Sampm="PM";
}
STimev+=b1(Shours)+":"+b1(Sminutes)+":"+b1(Sseconds)+" "+Sampm;
if(ie4){
document.all['time'].innerHTML = " Time:"+SloginDate+" "+STimev;
setTimeout('writeT()',1000);
}
}
function test(){
var today = new Date();
var yy = today.getYear();
if(yy<1900) yy = yy+1900;
document.all['test'].innerHTML = "2003 - "+yy+"Copyright";
}
</script>
</head>
<body onload="writeT()" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="56" bgcolor="#007A5E"> </td>
<td width="100%">
<table width="100%" style="background:url(images/top_bg.jpg)" border="0" cellspacing="0" cellpadding="0">
<tr height="70">
<td align="right"><img src="images/log.jpg"/> </td>
<td width="500"><img src="images/font.png" width="500px"/></td>
<td width="700"> </td>
<td width="300">当前时间:
<script language="javascript">writeT();</script>
</td>
</tr>
</table> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询