全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
JAVAscript实现时钟function $(id)return document.getElementById(id);function GDT_0() this.clockColor = blue; this.dispDay = -1; / Static globals. this.mhOffset = -90; this.hhOffset = -90; / Browser detection. this.agt = navigator.userAgent.toLowerCase(); this.is_ie = (this.agt.indexOf(msie)!= -1 & document.all & this.agt.indexOf(opera) = -1); this.is_ie5 = this.is_ie & (this.agt.indexOf(msie 5) != -1); this.is_ie6 = this.is_ie & (this.agt.indexOf(msie 6) != -1); this.is_ie7 = this.is_ie & (this.agt.indexOf(msie 7) != -1); /* * Writes an elements html for browsers with getElementById() */ this.writeElement = function(eltId, str) $(eltId).innerHTML = str; /* * Changes the clipping (position) of an elements background image for browsers with getElementById() */ this.updateX = function(eltId, xCoord) $(eltId).style.left = + xCoord + px; /* * Save the background image. */ this.setBkgPng = function (elId, imgSrc, repeat) $(elId).style.backgroundImage = url( + imgSrc + ); $(elId).style.backgroundRepeat = repeat; /* * Apply a filter instead of saving the background image. */ this.fixIeBkgPng = function (elId, imgSrc, repeat) $(elId).style.filter = progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, src=+imgSrc+); $(elId).style.backgroundImage = none; /* * Updates the clock to the current time. */ this.upClock = function() var ctime = new Date(); var phr = ctime.getHours(); var pmin = ctime.getMinutes(); / scale clock to 0 - 11 if (phr = 12) phr -= 12; / adjust background positions for hands. with adjustments to fix slight deviations in position. var minVal = (phr * 60 + pmin) / 720; var hrAdjust = Math.round(Math.sin(minVal * 2 * Math.PI) * 10); var minAdjust = Math.round(Math.sin(pmin / 60 * 2 * Math.PI) * 20); this.updateX(gdt_hands_h_0, Math.round(minVal * 36) * this.hhOffset + hrAdjust ); this.updateX(gdt_hands_m_0, pmin * this.mhOffset + minAdjust); /* * Sets up the clock to update every minute. */ this.startInterval = function() window.setInterval(GDT_0_handle.upClock(),60000); this.upClock(); this.setImages = function() if (this.is_ie5 | this.is_ie6) this.fixIeBkgPng(gdt_clock_0, /attachments/2007/4/27/20070427_54a48efa25186a4ba3dff36XuK2hnwO6.png, no-repeat); this.fixIeBkgPng(gdt_hands_m_0, /attachments/2007/4/27/20070427_98ad389bbcd247e01ba01I1NX4klASfF.png, no-repeat); this.fixIeBkgPng(gdt_hands_h_0, /attachments/2007/4/27/20070427_1d5c1cfac885bbb69019s8eQ98OXqbtF.png, no-repeat); else this.setBkgPng(gdt_clock_0, /attachments/2007/4/27/20070427_54a48efa25186a4ba3dff36XuK2hnwO6.png, no-repeat); this.setBkgPng(gdt_hands_m_0, /attachments/2007/4/27/20070427_98ad389bbcd247e01ba01I1NX4klASfF.pngg, no-repeat); this.setBkgPng(gdt_hands_h_0, /attachments/2007/4/27/20070427_1d5c1cfac885bbb69019s8eQ98OXqbtF.png, no-repeat); /* * Sets up the clock, and tries its best to sync with the system clock to update at the right time. */ this.main = function() / address differences in relatively positioned elements in different browsers if (!this.is_ie5 & !this.is_ie6 & !this.is_ie7) $(gdt_hands_0).style.position = relative; this.setImages(); this.upClock()
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 医疗资源整合与协同治理
- 合并慢性肾脏病的肺动脉高压靶向药物剂量策略
- 可穿戴设备在膀胱康复训练中的依从性提升策略
- 2025年国际海运货运合同协议
- 口腔疾病AI数字化诊断方案
- 2025广西北海福成机场第二季度实习、见习生招聘26人笔试备考试题附答案
- 2025广西城轨工程建设有限公司招聘20人笔试参考题库附答案
- 儿科疾病诊疗指南应用与改进
- 双抗的干细胞治疗联合策略
- 原发性肾上腺皮质功能不全的激素替代方案-1
- JJF 2216-2025电磁流量计在线校准规范
- 高处安装维护拆除作业培训
- 研究生培养管理教育
- 2025年小学生科普知识竞赛练习题库及答案(200题)
- 2025青鸟消防应急疏散余压探测器JBF5634、JBF5635
- (完整版)保密工作奖惩制度
- 营养科培训课件
- 2025年上海宝山区高三期末一模高考英语试卷(含答案详解)
- 互联网金融(同济大学)知到智慧树章节测试课后答案2024年秋同济大学
- 电力行业总经理年度工作述职报告范文
- 《ERCP的麻醉》课件:深入解析诊疗过程中的麻醉管理
评论
0/150
提交评论