(1): First with JS to write real-time display system time function Clockon () only a parameter bgclock, used to specify the display for the conversion of the name of the <div> tag, no return value, you can change the function of Web site development in the JS file, in order to reuse The code is as follows:
Copy Code code as follows:
<script>
function Clockon (bgclock)
{
var now = new Date ();
var year = Now.getyear ();
var month = Now.getmonth ();
var date = Now.getdate ();
var day = Now.getday ();
var hour = now.gethours ();
var minu = Now.getminutes ();
var sec = Now.getseconds ();
VAR week;
month = month+1;
if (month<10) month= "0" +month;
if (date<10) date= "0" +date;
if (hour<10) hour= "0" +hour;
if (minu<10) minu= "0" +minu;
if (sec<10) sec= "0" +SEC;
var arr_week = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
Week = Arr_week[day];
var time = "";
Time = year+ "year" +month+ "month" +date+ "Day" +week+ "" +hour+ "; +minu+ ";" +sec;
if (document.all)
{
Bgclock.innerhtml= "[" +time+ "]"
}
var timer = settimeout ("Clockon (Bgclock)", 200);
}
</script>
(2): Call in the <body> onload event of the page and place the DIV tag code where you want to display it:
Copy Code code as follows:
<body onload= "Clockon (bgclock)" >
<div id= "Bgclock" class= "Word_green" ></div>
</body>