


全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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版房地产精装修施工合同包含建筑节能认证服务
- 二零二五年新能源企业劳动保密及保密义务协议
- 2025版车辆买卖合同担保及车辆改装服务范本
- 2025版花卉进出口贸易合同
- 2025版某局信息化项目劳务分包结算规范合同
- GB/T 25751-2010压缩气弹簧技术条件
- GB/T 19137-2003农药低温稳定性测定方法
- 《中风的中医辨证论治(论文)4000字》
- 学院绩效考核办法和考核细则
- DBJ41∕T 225-2019 建筑施工斜拉悬挑式卸料平台安全技术标准-(高清版)
- 宗族祠堂的当代文化价值
- 网店开设与运营实战教程教学ppt课件(完整版)
- GB∕T 3185-2016 氧化锌(间接法)
- 南京南站明挖隧道施工方案
- DB37∕T 5023-2014 非透明幕墙建筑外保温系统应用技术规程
- 电网调度自动化维护员岗位培训题库简答题
评论
0/150
提交评论