dw中如何制作时间动态代码?
用 ‘dreamweaver’ 的工具 的编写 HTML 代码、用 javascript 实现 页面动态的显示时 间的代码
代码:
<HTML>
<head>
<title></title> <script>
function getDateDemo(){
//分别获取年、月、日、时、分、秒
var myDate = new Date();
var year = myDate.getFullYear();
var month = myDate.getMonth() + 1;
var date = myDate.getDate();
var hours = myDate.getHours();
var minutes = myDate.getMinutes();
var seconds = myDate.getSeconds();
//月份的显示为两位数字如09月
if(month < 10 ){
month = "0" + month;
}
if(date < 10 ){
date = "0" + date;
}
//时间拼接
var dateTime = year + "年" + month + "月" + date + "日" + hours + "时" + minutes + "分" +
seconds + "秒";
//document.write(dateTime);//打印当前时间
var divNode = document.getElementById("time");
divNode.innerHTML = dateTime;
}
window.setInterval("getDateDemo()",1000);//每隔1秒,调用一次getDateDemo()
</script>
</head>
<Body>
<DIV id="time"></DIV>
</Body>
</HTML>
---------------------------------------------------------------
<div id="linkweb">
</div>
<script>setInterval("linkweb.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);
</script>
2024-09-19 广告