...

View Full Version : How to pause javascript from scrolling on status bar



Dominios
06-24-2006, 11:24 PM
hi!

i downloaded a nice script to show up messages on the status bar, but i would like to show the messages only for two minutes, how do i pause it after 2 minutes? or after running the messages X times?

thanks guys for your help! ; ) im such a newbie!

Jeimy


<script language="JavaScript">

var speed = 5
var pause = 2500
var timerID = null
var bannerRunning = false
var ar = new Array()
ar[0] = " Message"
ar[1] = " Message"
ar[2] = " Message"
ar[3] = " Message"
ar[4] = " Message"
ar[5] = " Message"
ar[6] = " Message "
ar[7] = " Message "
ar[8] = " Message "
ar[9] = " Message"
ar[10] = " Message "
ar[11] = " Message "
var currentMessage = 0
var offset = 0
function stopBanner() {
if (bannerRunning)
clearTimeout(timerID)
bannerRunning = false
}
function startBanner() {
stopBanner()
showBanner()
}
function showBanner() {
var text = ar[currentMessage]
if (offset < text.length) {
if (text.charAt(offset) == " ")
offset++
var partialMessage = text.substring(0, offset + 1)
window.status = partialMessage
offset++ // IE sometimes has trouble with "++offset"
timerID = setTimeout("showBanner()", speed)
bannerRunning = true
} else {
offset = 0
currentMessage++
if (currentMessage == ar.length)
currentMessage = 0
timerID = setTimeout("showBanner()", pause)
bannerRunning = true
}
}
startBanner();
// -->
</script>

vwphillips
06-24-2006, 11:52 PM
function startBanner() {
setTimeout('stopBanner()',2*60*60*1000);
stopBanner()
showBanner()
}

Dominios
06-25-2006, 10:47 AM
thanks a lot!!! :thumbsup: this forum is the best! :)

Though just one question to learn a bit about this:
if " setTimeout('stopBanner()',2*60*60*1000); " is to stop after 2 minutes, what about 4 minutes? is it " setTimeout('stopBanner()',4*60*60*1000); " or " setTimeout('stopBanner()',4*60*60*60*60*1000); " ? or something different? :confused: Thanks! -Im sorry i have another website and i would like to run it there for longer time, so thats why i want to learn what 2*60*60*1000); means. Thanks! ;)

vwphillips
06-25-2006, 03:18 PM
setTimeout('stopBanner()',2*60*60*1000);

got a bit carried away with this

time is in milli Seconds

1 Second = 1000 mill Sec
1 Minute = 60 Sec

therefore should be

2*60*1000



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum