عرض مكتب الاستقبال صفحة
نسخة الكود كما يلي:
<span id = "clock" style = "font-size: 14px ؛"> </span>
نص JS
نسخة الكود كما يلي:
$ (وثيقة). ready (function () {
// النوع الأول
موعد العرض()؛
// النوع الثاني
var clock = clock new () ؛
clock.display ($ ("#clock")) ؛
}) ؛
// يتم عرض الطريقة الأولى لمعالجة الوقت الحالي للنظام
وظيفة showtime () {
var myarray = صفيف جديد (7) ؛
var td = new date () ؛
myarray [0] = "الأحد" ؛
myarray [1] = "Monday" ؛
myarray [2] = "الثلاثاء" ؛
myarray [3] = "الأربعاء" ؛
myarray [4] = "الخميس" ؛
myarray [5] = "الجمعة" ؛
myarray [6] = "Saturday" ؛
أيام الأسبوع = td.getDay () ؛
var h = td.gethours () ؛
var m = td.getMinutes () ؛
var s = td.getSeconds () ؛
var HSTR = H ؛
var mstr = m ؛
var isr = s ؛
if (h <10) {hstr = "0" + h} ؛
if (m <10) {mstr = "0" + m} ؛
if (s <10) {isr = "0" + s} ؛
$ ("#clock"). innerhtml ('الوقت الحالي:' + date () ؛
setTimeout (Showtime ، 1000) ؛
}
// يتم عرض الطريقة الثانية لمعالجة الوقت الحالي للنظام
وظيفة clock () {
var date = new date () ؛
this.year = date.getlyear () ؛
this.month = date.getMonth ()+1 ؛
this.date = date.getDate () ؛
this.day = Newarray ("Sunday" ، "Monday" ، "Tuesday" ، "Wednesdenne" ، "Dustome" ، "Friday" ، "Saturday") [Date.getDay ()] ؛
this.hour = date.gethours () <10؟ "0"+date.gethours (): date.gethours () ؛
this.minute = date.getMinutes () <10؟ "0"+date.getMinutes (): date.getMinutes () ؛
this.second = date.getSeconds () <10؟ "0"+date.getSeconds (): date.getSeconds () ؛
this.toString = function () {
إرجاع "الوقت الحالي هو:"+this.year+"year"+this.month+"month"+this.date+"day"+this.hour+":"+this.minute+":"+this.second+""+ هذا.
} ؛
this.tosimpleDate = function () {
returnthis.year+"-"+this.month+"-"+this.date ؛
} ؛
this.todetaildate = function () {
returnThis.year+"-"+this.month+"-"+this.date+""+this.hour+":"+this.minute+":"+this.second ؛
} ؛
this.display = function (ele) {
varclock = newClock () ؛
ele.innerhtml = clock.toString () ؛
window.settimeout (function () {clock.display (eLe) ؛} ، 1000) ؛
} ؛
}