Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to pause javascript from scrolling on status bar

    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>

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,503
    Thanks
    3
    Thanked 500 Times in 487 Posts
    Code:
    function startBanner() {
    setTimeout('stopBanner()',2*60*60*1000);
    stopBanner()
    showBanner()
    }
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks a lot!!! 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? 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!

  • #4
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,503
    Thanks
    3
    Thanked 500 Times in 487 Posts
    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
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •