<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title> Example1 </title>
<style>
body{font-size:34px;color:green;font-weight:bold}
</style>
<script></script>
<script language="JavaScript" type="text/javascript">
<!--
/*document.write("Hello Word !" + "<br>");
//这里是单行注释,这里将不被显示。
document.write(new Date()+"<br>");
这里是多行注释。
在这个区域里的内容都不会被显示。
document.write(new Date().toGMTString()+"<br>");
var date = new Date();
document.write(date.getTime()+"<br>");*/
//-->
</script>
<script language="JavaScript" type="text/javascript" src="Exp.js">
</script>
<script language="JavaScript" type="text/javascript">
<!--
function showTime(){
var currentTime = new Date();
var strDate = currentTime.getYear() + '年';
strDate += currentTime.getMonth() + '月';
strDate += currentTime.getDate() + '日';
strDate += currentTime.getHours() + ':';
strDate += currentTime.getMinutes() + ':';
var second = currentTime.getSeconds();
if(second<10){
strDate += '0' + currentTime.getSeconds();
}else{
strDate += currentTime.getSeconds();
}
alert(strDate);
}
//-->
</script>
<noscript>您的浏览器不支持脚本语言的运行</noscript>
</head>
<body>
<hr>
<b><font size="45px" color="red">这里是body标签里的文本</font></b>
<br><br>
<hr>
<center>
<form method=post action="#">
<input type="button" name="button" value="显示时间"
οnclick="var currentTime = new Date();
var strDate = currentTime.getYear() + '年';
strDate += currentTime.getMonth() + '月';
strDate += currentTime.getDate() + '日';
strDate += currentTime.getHours() + ':';
strDate += currentTime.getMinutes() + ':';
var second = currentTime.getSeconds();
if(second<10){strDate += '0' + currentTime.getSeconds();
}else{strDate += currentTime.getSeconds();}
alert(strDate);"/>
<input type="button" name="button" value="显示时间" οnclick="javascript:showTime()"/>
</form>
<a href="javascript:showTime();alert('欢迎学习JavaScript')">显示时间</a>
</center>
</body>
</html>