


全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 济宁市2024-2025学年七年级上学期语文期中测试试卷
- 电路基础知识大专培训广州课件
- 高速换电站基础知识培训
- 打工人的30个DeepSeek提示词
- 高血压糖尿病课件
- 高血压原理课件
- python大学考试大题及答案
- 电缆焊接入门知识培训课件
- 山东省聊城市莘县2022-2023学年九年级上学期期中化学试题(含答案)
- 电磁铁磁力课件
- 混改公司合同协议模板
- 儿童多种维生素课件
- GA/T 2159-2024法庭科学资金数据清洗规程
- 2025年职工职业技能竞赛(物业管理师)参考试题(附答案)
- 成人肠造口护理要点与实践课件
- 会务服务面试题及答案
- 2025年人教版小学四年级数学上册全册单元检测试卷(全套版)
- 2025年体育与健康教材教法考试模拟试卷及答案
- 2025年江西省高职单招文化统一考试真题及答案(网络版)
- 《医疗机构重大事故隐患判定清单(试行)》知识培训
- 水行政处罚培训课件
评论
0/150
提交评论