想弄个开学倒计时的页面,结果不知是没有调用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>倒计时</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">
-->
<script>
function countdown(title, Intime, divId) {
var online = new Date(Intime); //自定义时间
var now = new Date(); //获取当前时间
var leave = online.getTime() - now.getTime(); //计算时间差
var day = Math.floor(leave / (60 * 60 * 24 * 1000)) + 1;
if (day > 1) {
if (document.all) {
divId.innerHTML = "<b>---距" + title + "还有" + day + "天!</b>";
}
}
else if (day == 1){
if (document.all) {
divId.innerHTML = "<b>---明天就是" + title + "啦!</b>";
}
}
else if (day == 0) {
if (document.all) {
divId.innerHTML = "<b>---今天就是" + title + "啦!</b>";
}
}
else {
if (document.all) {
divId.innerHTML = "<b>---已经过" + title + "啦!</b>";
}
}
}
</script>
</head>
<body>
<table width="350" height="450" border="0" align="center"
cellpadding="0" cellspacing="0">
<tr>
<td valign="bottom">
<table width="346" height="418" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td width="76"></td>
<td width="270">
<div id="countDown">
<b>---</b>
</div> <script language="javascript">
document.write("text");
countdown("开学", "28/8/2017", "countDown");
</script>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>

代码如下:
<%@ 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>倒计时</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">
-->
<script>
function countdown(title, Intime, divId) {
var online = new Date(Intime); //自定义时间
var now = new Date(); //获取当前时间
var leave = online.getTime() - now.getTime(); //计算时间差
var day = Math.floor(leave / (60 * 60 * 24 * 1000)) + 1;
if (day > 1) {
if (document.all) {
divId.innerHTML = "<b>---距" + title + "还有" + day + "天!</b>";
}
}
else if (day == 1){
if (document.all) {
divId.innerHTML = "<b>---明天就是" + title + "啦!</b>";
}
}
else if (day == 0) {
if (document.all) {
divId.innerHTML = "<b>---今天就是" + title + "啦!</b>";
}
}
else {
if (document.all) {
divId.innerHTML = "<b>---已经过" + title + "啦!</b>";
}
}
}
</script>
</head>
<body>
<table width="350" height="450" border="0" align="center"
cellpadding="0" cellspacing="0">
<tr>
<td valign="bottom">
<table width="346" height="418" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td width="76"></td>
<td width="270">
<div id="countDown">
<b>---</b>
</div> <script language="javascript">
document.write("text");
countdown("开学", "28/8/2017", "countDown");
</script>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>