(1): First, use JS to write the function clockon() that displays the system time in real time. It has only one parameter bgclock, which is used to specify the name of the converted
tag. There is no return value. Everyone is developing the website. You can save the modified function in a JS file for reuse. The code is as follows:
<script><br>function clockon(bgclock)<br>{<br> var now = new Date();<br> var year = now.getYear();<br> var month = now .getMonth();<br> var date = now.getDate();<br> var day = now.getDay();<br> var hour = now.getHours();<br> var minu = now.getMinutes ();<br> var sec = now.getSeconds();<br> var week;<br> month = month 1;<br> if(month<10)month="0" month;<BR> if( date<10)date="0" date;<BR> if(hour<10)hour="0" hour;<BR> if(minu<10)minu="0" minu;<BR> if(sec< 10)sec="0" sec;<BR> var arr_week = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");<BR> week = arr_week[day];<BR> var time = "";<BR> time = year "year" month "month" date "day" week "" hour ";" minu ";" sec;<BR> if(document.all)<BR> {<BR> bgclock.innerHTML="[" time "]"<BR> }<BR> var timer = setTimeout("clockon(bgclock)",200); <BR>} <BR></script>
(2): Call in the onload event of the page's
and place the div tag where it is to be displayed. Code:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31