我一直收到这样的错误消息:
未登录的SyntaxError:意外标识符
当将毫秒加到时钟中时。我是从一本书上抄出来的,所以我不知道出了什么问题。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN">
<html>
<head>
<title>Event Test</title>
</head>
<body>
<h1>Event Test</h1>
<script type="text/javascript">
now = new Date();
localtime = now.toString();
utctime = now.toGMTString();
document.write("<strong>Local time:</strong> "
+ localtime + "<br/>");
document.write("<strong>UTC time:</strong> " +
utctime);
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
mil = now.getMilliseconds();
document.write("<h1>");
document.write(hours + ":" + minutes + ":" + seconds + ":" mil);
document.write("</h1>");
</script>
</body>
</html>发布于 2012-10-12 02:46:25
看起来你在这里错过了一个+:
document.write(hours + ":" + minutes + ":" + seconds + ":" mil);
//--------------------------------------------------------^^^^发布于 2012-10-12 02:47:58
线
document.write(hours + ":" + minutes + ":" + seconds + ":" mil);应改为
document.write(hours + ":" + minutes + ":" + seconds + ":" + mil);在+之前缺少一个mil
发布于 2012-10-12 02:51:57
你错过了一个+
document.write(hours + ":" + minutes + ":" + seconds + ":" + mil);https://stackoverflow.com/questions/12851481
复制相似问题