• home
  • forum
  • my
  • kt
  • download
  • Status Bar Left to Right TextScroll

    Author: 2007-08-08 09:39:25 From:

    In this article we are going to design a JavaScript Left to right text scroll at windows Status Bar. Take a look below on piece of code¡­

    var YourMess = "TechXcel.com - provides technical excellence... ";
    var space = "";
    var msg = "";
    var LeftMsg = "";
    function MsgFLY(){

        if (msg == "")
    {
        space = " ";
        msg = YourMess;
        LeftMsg = "";
    }

        if (space.length == 1)
    {
        while (msg.substring(0, 1) == " ")
        {
        LeftMsg = LeftMsg + space;
        space = msg.substring(0, 1);
        msg = msg.substring(1, msg.length);
        }
        LeftMsg = LeftMsg + space;
        space = msg.substring(0, 1);
        msg = msg.substring(1, msg.length);
            for (var ii = 0; ii < 120; ii++)
        {
        space = " " + space;
        }
    }
    else
        space = space.substring(10, space.length);
        window.status = LeftMsg + space;
        timeout = window.setTimeout('MsgFLY()',100);
    }
    timeout = window.setTimeout('MsgFLY()',500);

    Now we define a function MsgFLY() and going to call it through Window object supports methods setTimeout() to call same function after every 1000 milliseconds. The Window object supports methods for setting timers that we might use to perform a variety of functions. These methods include setTimeout() and clearTimeout(). The basic idea is to set a timeout to trigger a piece of script to occur at a particular time in the future. The general syntax is
     timerId = setTimeout(script-to-execute, time-in-milliseconds);

    As the MsgFLY() get called after every 500 milliseconds recursively. Here we have define 4 variables¡­ YourMess, space,msg, Leftmsg. And then assign YourMess text to msg and a blank space to space. Now we are going to split our message to display at status bar by using msg.substring. msg.substring extracts characters

    Syntax:
    substring(A, [B])

    Parameters:
    A : An integer between 0 and one less than the length of the string.
    B : (optional) An integer between 0 and the length of the string.

    substring extracts characters from indexA up to but not including indexB. In particular:

    If A equals B, substring returns an empty string.
    If B is omitted, substring extracts characters to the end of the string.
    If either argument is less than 0 or is NaN, it is treated as if it were 0.
    If either argument is greater than stringName.length, it is treated as if it were stringName.length.

    For example: -
    // assumes a print function is defined
    var anyString = "TechXcel";
    // Displays "Tech"
    print(anyString.substring(0,4));


    And then we are adding blank space to it and then display it at status clock of web browser. see image below...

    discuss this topic to forum

    relation tutorial

    No relevant information

    Category

      AJAX (20)
      Content Management (7)
      Cookies (4)
      Date and Time (12)
      Development (7)
      DHTML (14)
      Forms (8)
      Frequently Asked Questions (1)
      Image Display (9)
      Introduction to Javascript (5)
      Links and Buttons (4)
      Menus (2)
      Miscellaneous (5)
      Mouse Tricks (3)
      Navigation (8)
      Randomizing (4)
      Security (1)
      Text Effects (6)
      User Authentication (2)
      User Information (5)
      Windows and Frames (3)

    New

    Hot