javascript实现时钟的多种方法
2007-05-06 19:39
1066 查看
<!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="显示时间"
onclick="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="显示时间" onclick="javascript:showTime()"/>
</form>
<a href="javascript:showTime();alert('欢迎学习JavaScript')">显示时间</a>
</center>
</body>
</html>
<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="显示时间"
onclick="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="显示时间" onclick="javascript:showTime()"/>
</form>
<a href="javascript:showTime();alert('欢迎学习JavaScript')">显示时间</a>
</center>
</body>
</html>
相关文章推荐
- javascript多种方法实现数组去重
- javascript实现模拟时钟的方法
- JavaScript 实现类的多种方法实例
- javascript实现数组去重的多种方法
- Javascript/Jquery——简单定时器的多种实现方法
- Javascript/Jquery――简单定时器的多种实现方法
- JavaScript实现类,有多种方法。
- javascript背景时钟实现方法
- javascript实现保留两位小数的多种方法
- javascript实现保留两位小数的多种方法
- JavaScript 多种方法实现类(转)
- javascript实现保留两位小数的多种方法
- javascript实现数组去重的多种方法
- JavaScript 多种方法实现类
- Javascript/Jquery――简单定时器的多种实现方法
- javascript实现保留两位小数的多种方法
- javascript小实例,多种方法实现数组去重问题
- javascript实现模拟时钟的方法