Clock.innerHTML=innerString;Clock.innerHTML=timeString;
解决方案 »
- 求大神帮助,jquery 查看div中href引入页面中的元素。
- 求助 ExtJS
- 如何用js脚本实现按钮先获得鼠标所选的内容并实现上下标功能
- 怎样移动文本框的焦点到末尾?
- 动态向DIV里写入JS
- scrollHeight 的正确含义
- padding-left 跟cellpadding什么区别
- 请教,如何实现选中一个文本框后,边框边色
- 关于iframe中嵌套一个JSP的问题
- 真的没人会????http://expert.csdn.net/Expert/topic/2594/2594654.xml?temp=6.234378E-02
- 求教jsp中table导出excel的例子
- checkbox全先和反选
下面这个才是<html>
<head>
<title>网页时钟2</title>
<script language="javascript">
function tick()
{
var hours,minutes,seconds,xfile;
var intHours,intMinutes,intSeconds;
var today;
today=new Date();
intHours=today.getHours();
intMinutes=today.getMinutes();
int Seconds=today.getSeconds();
if(intHours==0)
{
hours="12:";
xfile="现在是午夜,该休息了";
}
else if(intHours<12)
{
hours=intHours+":";
xfile="现在是上午,新的一天开始了";
}
else if(intHours==12)
{
hours="12:";
xfile="现在是正午,该吃饭了";
}
else
{
intHours-=12;
hours=intHours+":";
xfile="现在是下午,抓紧时间吧";
}
if(intMinutes<10)
{
minutes="0"+intMinutes+":";
}
else
{
minutes=intMinutes+":";
}
if(intSeconds<10)
{
seconds="0"+intSeconds;
}
else
{
seconds=intSeconds;
}
timeString=xfile+hours+minutes+seconds;
Clock.innerHTML=timeString;
window.setTimeout("tick();",100);
}
window.onload=tick;
</script>
</head>
<body>
<div id="Clock" align="center" style="font-size:20;color:#000000"></div>
</body>
</html>
Clock.innerHTML=innerString; 看到没?
红色部分
不一样,怎么显示
innerString你这个都还没定义
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="JavaScript">
<!--
function tick() {
var hours,minutes,seconds,ap;
var intHours,intMinutes,intSeconds;
var today;
var timeString;
today=new Date(); intHours=today.getHours();
intMinutes=today.getMinutes();
intSeconds=today.getSeconds();
if (intHours==0) {
hours="12" ;
ap="Midnight";
}
else if (intHours<12) {
hours=intHours+":" ;
ap="A.M.";
}
else if(intHours==12) {
hours="12" ;
ap="Noon";
}
else {
intHours=intHours-12
hours=intHours+":";
ap="P.M.";
} if (intMinutes<10) {
minutes="0"+intMinutes+":";
} else{
minutes=intMinutes+":";
}
if(intSeconds < 10) {
seconds="0"+intSeconds+":"
} else {
seconds=intSeconds+"";
}
timeString=hours+minutes+seconds+ap;
Clock.innerHTML=timeString;
window.setTimeout("tick();",100);
}
window.onload =tick; -->
</script> </head>
<body>
<h1>改变页面样式</h1>
<div id="Clock" align= center></div>
<table border==1>
<tr>
<td>时钟颜色</td>
<td>时钟背景</td>
<td>时钟字体</td>
<td>时钟尺寸</td>
<td>时钟粗细</td>
</tr>
<tr>
<td colspan="5"></td>
</tr>
<tr>
<td><span onmouseover="this.style.cursor='hand'"
onmouseout="this.style.cursor='default'"
onClick="Clock.style.color='purple'">紫色</span>
</td> <td><span onmouseover="this.style.cursor='hand'"
onmouseout="this.style.cursor='default'"
onClick="Clock.style.background='red'">红色</span>
</td> <td><span onmouseover="this.style.cursor='hand'"
onmouseout="this.style.cursor='default'"
onClick="Clock.style.fontFamily='verdana'">无边试</span>
</td> <td><span onmouseover="this.style.cursor='hand'"
onmouseout="this.style.cursor='default'"
onClick="Clock.style.fontSize='24pt'">24pt</span>
</td> <td><span onmouseover="this.style.cursor='hand'"
onmouseout="this.style.cursor='default'"
onClick="Clock.style.fontWeight='normal'">普通</span>
</td>
</tr> <tr>
<td><span onmouseover="this.style.cursor='hand'"
onmouseout="this.style.cursor='default'"
onClick="Clock.style.color='white'">白色</span>
</td> <td><span onmouseover="this.style.cursor='hand'"
onmouseout="this.style.cursor='default'"
onClick="Clock.style.background='yellow'">黄色</span>
</td> <td><span onmouseover="this.style.cursor='hand'"
onmouseout="this.style.cursor='default'"
onClick="Clock.style.fontFamily='Georgia'">有边试</span>
</td> <td><span onmouseover="this.style.cursor='hand'"
onmouseout="this.style.cursor='default'"
onClick="Clock.style.fontSize='36pt'">36pt</span>
</td> <td><span onmouseover="this.style.cursor='hand'"
onmouseout="this.style.cursor='default'"
onClick="Clock.style.fontWeight='bold'">组体</span>
</td>
</tr> </table>
</body>
</html>
下面这个才是<html>
<head>
<title>网页时钟2</title>
<script language="javascript">
function tick()
{
var hours,minutes,seconds,xfile;
var intHours,intMinutes,intSeconds;
var today;
today=new Date();
intHours=today.getHours();
intMinutes=today.getMinutes();
int Seconds=today.getSeconds();
if(intHours==0)
{
hours="12:";
xfile="现在是午夜,该休息了";
}
else if(intHours<12)
{
hours=intHours+":";
xfile="现在是上午,新的一天开始了";
}
else if(intHours==12)
{
hours="12:";
xfile="现在是正午,该吃饭了";
}
else
{
intHours-=12;
hours=intHours+":";
xfile="现在是下午,抓紧时间吧";
}
if(intMinutes<10)
{
minutes="0"+intMinutes+":";
}
else
{
minutes=intMinutes+":";
}
if(intSeconds<10)
{
seconds="0"+intSeconds;
}
else
{
seconds=intSeconds;
}
timeString=xfile+hours+minutes+seconds;
Clock.innerHTML=timeString;
window.setTimeout("tick();",100);
}
window.onload=tick;
</script>
</head>
<body>
<div id="Clock" align="center" style="font-size:20;color:#000000"></div>
</body>
</html>
下面这个才是<html>
<head>
<title>网页时钟2</title>
<script language="javascript">
function tick()
{
var hours,minutes,seconds,xfile;
var intHours,intMinutes,intSeconds;
var today;
today=new Date();
intHours=today.getHours();
intMinutes=today.getMinutes();
int Seconds=today.getSeconds();
if(intHours==0)
{
hours="12:";
xfile="现在是午夜,该休息了";
}
else if(intHours<12)
{
hours=intHours+":";
xfile="现在是上午,新的一天开始了";
}
else if(intHours==12)
{
hours="12:";
xfile="现在是正午,该吃饭了";
}
else
{
intHours-=12;
hours=intHours+":";
xfile="现在是下午,抓紧时间吧";
}
if(intMinutes<10)
{
minutes="0"+intMinutes+":";
}
else
{
minutes=intMinutes+":";
}
if(intSeconds<10)
{
seconds="0"+intSeconds;
}
else
{
seconds=intSeconds;
}
timeString=xfile+hours+minutes+seconds;
Clock.innerHTML=timeString;
window.setTimeout("tick();",100);
}
window.onload=tick;
</script>
</head>
<body>
<div id="Clock" align="center" style="font-size:20;color:#000000"></div>
</body>
</html>
我自己的代码是5L发的 实在是看不出什么错误……
我一直是做C/C++方面的东西 对这种解释执行的dubug真没啥经验……
today=new Date();
intHours=today.getHours();
intMinutes=today.getMinutes();
int Seconds=today.getSeconds(); // 你自己马虎了 int Seconds===》intSeconds