<head>
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
</head>
当前时间:
<div id="time">
<script>
document.getElementById('time').innerHTML = new Date().toLocaleString()
+ ' 星期' + '日一二三四五六'.charAt(new Date().getDay())
setInterval(
"document.getElementById('time').innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay())",
1000)
</script>
</div>
<body>
</body>
</html>
网上找的资料,可以使用。网页动态时钟的简单实现Javascript例一:通过表单访问元素
<html>
<head>
<script type="text/javascript">
function disptime()
{
var time=new Date()
var hour=time.getHours()
var minute=time.getMinutes()
var second=time.getSeconds()
document.form.myclock.value=hour+":"+minute+":"+second+""
var mytime=setTimeout("disptime()",1000)
}
</script>
<!--设定显示时间的文本框样式-->
<style type="text/css">
<!--设定显示时间的文本框样式
.inputStyle{
font-size: 30px
background-color: #FF6600
border-style:none
}
.STYLE1 {font-size: 24px}
-->
</style>
</head>
<body onLoad="disptime()"><!--当打开网页时即调用显示时间的方法-->
<form name="form">
<b>当前时间</b>
<input name="myclock" type="text" size="8" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />
<title>动态时间</title>
<script type="text/javascript">
function disptime()
{
var time= new Date()
var hour=time.getHours()
var minute=time.getMinutes()
var second=time.getSeconds()
document.getElementById("time").value=hour+":"+minute+":"+second+""
var myTime=setTimeout("disptime()",1000)
}
</script>
<style type="text/css">
<!--
/* 设置样式,无边框的文本框*/
.input{
font-size:30px
border-style:none
background-color:#FFFF00
}
-->
</style>
</head>
<body onload="disptime()">
<input id="time" type="text" size="10"/>
</body>
</html>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)