***时间日期***时间跳动器(有一点点爽爽。。)
把下列代码加到网页的<body></body>标签之间 从google下载我的照片管理软件脚本说明:
第一步:把如下代码加入<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 = 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 != '') {
if (--this.synccountdown <= 0) {
this.synccountdown = this.syncinterval
command += ';' + this.syncname + '.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 == name) {
newindex = i
break
}
}
if (newindex == this.synccount) {
this.synccount++
}
this.syncinterval = interval
this.synccountdown = interval
this.syncname = name
}
function timerappunsync (name) {
for (var i = 0; i < this.synccount; i++) {
if (this.syncname == name) {
this.syncname = ''
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.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">
--------------------------------------
http://www.huoyue.com.cn 活跃网,活跃人群的论坛,访问活跃网,将给您带来意想不到的收获,还可以免费为您开论坛,让您免费拥有与朋友、网友交流的论坛。你是年轻人吗?你活跃你就上!
页:
[1]