首页 考试吧论坛 Exam8视线 考试商城 网络课程 模拟考试 考友录 实用文档 求职招聘 论文下载
2011中考 | 2011高考 | 2012考研 | 考研培训 | 在职研 | 自学考试 | 成人高考 | 法律硕士 | MBA考试
MPA考试 | 中科院
四六级 | 职称英语 | 商务英语 | 公共英语 | 托福 | 雅思 | 专四专八 | 口译笔译 | 博思 | GRE GMAT
新概念英语 | 成人英语三级 | 申硕英语 | 攻硕英语 | 职称日语 | 日语学习 | 法语 | 德语 | 韩语
计算机等级考试 | 软件水平考试 | 职称计算机 | 微软认证 | 思科认证 | Oracle认证 | Linux认证
华为认证 | Java认证
公务员 | 报关员 | 银行从业资格 | 证券从业资格 | 期货从业资格 | 司法考试 | 法律顾问 | 导游资格
报检员 | 教师资格 | 社会工作者 | 外销员 | 国际商务师 | 跟单员 | 单证员 | 物流师 | 价格鉴证师
人力资源 | 管理咨询师考试 | 秘书资格 | 心理咨询师考试 | 出版专业资格 | 广告师职业水平
驾驶员 | 网络编辑
卫生资格 | 执业医师 | 执业药师 | 执业护士
会计从业资格考试会计证) | 经济师 | 会计职称 | 注册会计师 | 审计师 | 注册税务师
注册资产评估师 | 高级会计师 | ACCA | 统计师 | 精算师 | 理财规划师 | 国际内审师
一级建造师 | 二级建造师 | 造价工程师 | 造价员 | 咨询工程师 | 监理工程师 | 安全工程师
质量工程师 | 物业管理师 | 招标师 | 结构工程师 | 建筑师 | 房地产估价师 | 土地估价师 | 岩土师
设备监理师 | 房地产经纪人 | 投资项目管理师 | 土地登记代理人 | 环境影响评价师 | 环保工程师
城市规划师 | 公路监理师 | 公路造价师 | 安全评价师 | 电气工程师 | 注册测绘师 | 注册计量师
缤纷校园 | 实用文档 | 英语学习 | 作文大全 | 求职招聘 | 论文下载 | 访谈 | 游戏
您现在的位置: 考试吧(Exam8.com) > 软件水平考试 > 复习资料 > 网页制作 > 正文

网页特效:时间跳动器

  脚本说明:

  第一步:把如下代码加入<head>区域中

  <script language="Javascript">
  <!-- Hide this script from old browsers --
  function modRange (value, min, max) {
   if (min == max) {
    return (min)
   }
   var low = Math.min (min, max)
   var high = Math.max (min, max)
   var range = high - low + 1
   var valOff = parseInt (value) - low
   var mod = range * Math.floor (valOff / range)
   result = low + valOff - mod
   if (result < low) {
    result += high
   }
   if (result > high) {
    result = low
   }
   return (result)
  }
  function array () {
   this[0] = null
  }
  function timerAppStart () {
   this.stop ()
   this.loop ()
  }
  function timerAppStop () {
   clearTimeout (this.timeout)
   this.timeout = null
  }
  function timerAppToggle () {
   if (this.timeout) {
    this.stop ()
   } else {
    this.start ()
   }
  }
  function timerAppLoop () {
   this.update ()
   command = this.name + ‘.loop()‘
   for (var i = 0; i < this.syncCount; i++) {
    if (this.syncName[i] != ‘‘) {
     if (--this.syncCountdown[i] <= 0) {
     this.syncCountdown[i] = this.syncInterval[i]
     command += ‘;‘ + this.syncName[i] + ‘.update()‘
     }
    }
   }
   this.timeout = setTimeout (command, this.interval)
  }
  function timerAppSetOutput (output) {
   if (! this.output) {
    this.output = output
   }
  }
  function timerAppSetInterval (interval) {
   if (interval) {
    var newInterval = parseInt (interval)
    if (newInterval > 0) {
     this.interval = newInterval
    } else {
     alert (‘Interval value must be a positive number: ‘ + interval)
    }
   }
  }|||  function timerAppSync (name, interval) {
   if (interval == null) {
    interval = 1
   }
   if (interval <= 0) {
    eval (this.name + ‘.unsync("‘ + name + ‘")‘)
    return
   }
   var newIndex = this.syncCount
   for (var i = 0; i < this.syncCount; i++) {
    if (this.syncName[i] == name) {
     newIndex = i
     break
    }
   }
   if (newIndex == this.syncCount) {
    this.syncCount++
   }
   this.syncInterval[newIndex] = interval
   this.syncCountdown[newIndex] = interval
   this.syncName[newIndex] = name
  }
  function timerAppUnsync (name) {
   for (var i = 0; i < this.syncCount; i++) {
    if (this.syncName[i] == name) {
     this.syncName[i] = ‘‘
     if (i == (this.syncCount - 1)) {
     this.syncCount--
     }
    }
   }
  }
  function timerAppSetIncrement (increment) {
   if (increment) {
    var newIncrement = parseInt (increment)
    //*Unix only*   if (! isNan (newIncrement)) {
     if (newIncrement != 0) {
     this.increment = newIncrement
     } else {
     alert (‘Increment value must be a number: ‘ + increment)
    }
   }
  }
  function timerAppSetBounce (bounce) {
   if (bounce) {
    var newBounce = parseInt (bounce)
    //*Unix only*   if (! isNan (newBounce)) {
     if (newBounce != 0) {
     this.bounce = newBounce
     } else {
     alert (‘Bounce value must be a number: ‘ + bounce)
    }
   }
  }
  function timerAppSetOffset (offset) {
   if (offset) {
    var newOffset = parseInt (offset)
    if ((newOffset > 0)
    && (newOffset <= this.output.length)) {
     this.offset = newOffset
    } else {
     warnMessage = ‘Value of offset must be a valid index (0 - ‘
     + this.output.length + ‘): ‘ + offset
     alert (warnMessage)
    }
   }
  }
  function clock (name, output, interval) {
   // Initialize with default values
   this.name = name     // object name, needed for setTimeout
   this.output = null     // output area
   this.interval = 1000    // milliseconds
   this.timeout = null
   this.syncCount = 0
   this.syncName = new array ()
   this.syncInterval = new array ()
   this.syncCountdown = new array ()
   // Define object methods
   this.update = clockUpdate
   this.start = timerAppStart
   this.stop = timerAppStop
   this.toggle = timerAppToggle
   this.loop = timerAppLoop
   this.setOutput = timerAppSetOutput
   this.setInterval = timerAppSetInterval
   this.sync = timerAppSync
   this.unsync = timerAppUnsync
   // Initialize with specified values
   this.setOutput (output)
   this.setInterval (interval)
   this.start()
  }|||  function clockUpdate () {
   var now = new Date()
   var timeHH = now.getHours();
   var timeMM = now.getMinutes()
   var timeSS = now.getSeconds()
   var msec = now.getTime ()
   var timeSSm = msec - 1000 * Math.floor (msec / 1000)
   timeSSm = ‘00‘ + timeSSm
   timeSSm = timeSSm.substring(timeSSm.length-3, timeSSm.length)
   var timeString = ((timeHH < 10) ? ‘0‘ : ‘‘) + timeHH
   + ‘:‘ + ((timeMM < 10) ? ‘0‘ : ‘‘) + timeMM
   + ‘:‘ + ((timeSS < 10) ? ‘0‘ : ‘‘) + timeSS
   + ‘.‘ + timeSSm
   if (this.output) {
    this.output.value = timeString
   } else {
    self.status = timeString
   }
  }
  function buttons (name, output, interval, increment, bounce, offset) {
   // Initialize with default values
   this.name = name
   this.output = null
   this.interval = 1000
   this.increment = 1
   this.bounce = 1
   this.offset = 0
   this.timeout = null
   this.syncCount = 0
   this.syncName = new array ()
   this.syncInterval = new array ()
   this.syncCountdown = new array ()
   // Define object methods
   this.update = buttonsUpdate
   this.start = timerAppStart
   this.stop = timerAppStop
   this.toggle = timerAppToggle
   this.loop = timerAppLoop
   this.setOutput = timerAppSetOutput
   this.setInterval = timerAppSetInterval
   this.sync = timerAppSync
   this.unsync = timerAppUnsync
   this.setIncrement = timerAppSetIncrement
   this.setBounce = timerAppSetBounce
   this.setOffset = timerAppSetOffset
   // Initialize with specified values
   this.setOutput (output)
   this.setInterval (interval)
   this.setIncrement (increment)
   this.setBounce (bounce)
   this.setOffset (offset)
   this.start()
  }
  function buttonsUpdate () {
   if (this.output) {
    var newOffset = this.offset + this.increment
    if ((newOffset < this.output.length)
    && (newOffset >= 0)) {
     this.offset = newOffset
    } else {
     this.increment *= this.bounce
     if (this.increment >= 0) {
     this.increment = modRange (this.increment, 0, this.output.length-1)
     } else {
     this.increment = 0 - modRange (Math.abs (this.increment),
     0, this.output.length-1)
     }
     this.offset += this.increment
     this.offset = modRange (this.offset, 0, this.output.length-1)
    }
    this.output[this.offset].checked = true
   }
  }
  // -- End Hiding Here -->
  </script>

|||

  第二步:把如下代码加入<body>区域中

  <FORM NAME=‘clock‘ ACTION=‘‘>
  <TABLE BORDER=2><TR><TD>
  <FONT SIZE=-2>
  <INPUT TYPE=‘text‘ NAME=‘display‘ SIZE=8
  onFocus=‘wClock.toggle()‘
  onMouseOver=‘self.status="Click here to turn on/off clock"; return true‘>
  </FONT>
  </TD></TR></TABLE>
  </FORM>
  <FORM NAME=‘imastudios‘>
  <P>
  <INPUT TYPE=‘radio‘ NAME=‘buttons‘>
  Tick
  <INPUT TYPE=‘radio‘ NAME=‘buttons‘>
  Tock
  <INPUT TYPE=‘radio‘ NAME=‘buttons‘>
  Tick
  <INPUT TYPE=‘radio‘ NAME=‘buttons‘>
  Tock
  <INPUT TYPE=‘radio‘ NAME=‘buttons‘>
  Tick
  </FORM>

  第三步:把<body>区中内容改为

  <body bgcolor="#fef4d9" onLoad=‘wClock = new clock ("wClock", document.clock.display); wButtons = new buttons ("wButtons", document.imastudios.buttons, 500, 1,-1); wButtons.stop(); wClock.sync ("wButtons", 1)‘onUnload=‘wClock.stop(); wButtons.stop()‘ bgcolor="#FFFFFF">

1 2  下一页
文章搜索
软件水平考试栏目导航
版权声明:如果软件水平考试网所转载内容不慎侵犯了您的权益,请与我们联系800@exam8.com,我们将会及时处理。如转载本软件水平考试网内容,请注明出处。