环境:Visual Studio 2008
语言:C#
程序:ASP.NET 我新建了一个母版页文件,想在其公共部分实现汉字"今天是"+"x年x月x日".代码如下: <tr>
<td colspan="2" align="left">
今天是<script language="javascript">showtime();</script>
</td>
</tr>其中showtime()方法代码如下:
<script language="javascript">
function showtime()
{
var now= new Date();
years = now.getFullYear();
month = now.getMonth()+1;
dates = now.getDate();
hours = now.getHours();
Minutes = now.getMinutes();
Seconds = now.getSeconds();
if (hours<10)
hours="0"+hours;
if(Minutes<10)
Minutes="0"+Minutes;
if (Seconds<10)
Seconds="0"+Seconds;
var titletext = years + "年" + month + "月" + dates + "日" +hours +":" + Minutes + ":" + Seconds;
setTimeout("showtime()",1000);
document.write(titletext);
//Label1.innerHTML= titletext;
//showtime();
}
</script>运行之后的页面满篇都是时间,请大家帮我看看,我的代码到底错在哪里?该怎么写?谢谢!!!!
语言:C#
程序:ASP.NET 我新建了一个母版页文件,想在其公共部分实现汉字"今天是"+"x年x月x日".代码如下: <tr>
<td colspan="2" align="left">
今天是<script language="javascript">showtime();</script>
</td>
</tr>其中showtime()方法代码如下:
<script language="javascript">
function showtime()
{
var now= new Date();
years = now.getFullYear();
month = now.getMonth()+1;
dates = now.getDate();
hours = now.getHours();
Minutes = now.getMinutes();
Seconds = now.getSeconds();
if (hours<10)
hours="0"+hours;
if(Minutes<10)
Minutes="0"+Minutes;
if (Seconds<10)
Seconds="0"+Seconds;
var titletext = years + "年" + month + "月" + dates + "日" +hours +":" + Minutes + ":" + Seconds;
setTimeout("showtime()",1000);
document.write(titletext);
//Label1.innerHTML= titletext;
//showtime();
}
</script>运行之后的页面满篇都是时间,请大家帮我看看,我的代码到底错在哪里?该怎么写?谢谢!!!!
问题不在ShowTime()
布局问题,把源码贴出来看看..
<head runat="server">
<title>无标题页</title>
<script language="javascript">
function showtime()
{
var now= new Date();
years = now.getFullYear();
month = now.getMonth()+1;
dates = now.getDate();
hours = now.getHours();
Minutes = now.getMinutes();
Seconds = now.getSeconds();
if (hours<10)
hours="0"+hours;
if(Minutes<10)
Minutes="0"+Minutes;
if (Seconds<10)
Seconds="0"+Seconds;
var titletext = years + "年" + month + "月" + dates + "日" +hours +":" + Minutes + ":" + Seconds;
setTimeout("showtime()",1000);
document.write(titletext);
//Label1.innerHTML= titletext;
//showtime();
}
</script>
</head>
<body>
<div>
<table border="1" style="width:80%; height:100% ">
<tr>
<td colspan="2" align="center">
<img src="images/img01.jpg"/>
</td>
</tr>
<tr>
<td colspan="2" align="left">
今天是<script language="javascript">showtime();</script>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
<tr>
<td colspan="2" align="center">
©2007 myBookroom
</td>
</tr>
</table>
</div>
</body>
</html>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
把这句不要放到Table里试试!