Skip to content

TechXcel.com - provides technical excellence...

Narrow screen resolution Wide screen resolution Increase font size Decrease font size Default font size default color orange color green color
You are here: Home arrow Articles arrow JavaScript arrow Status Bar Left to Right TextScroll
Status Bar Left to Right TextScroll PDF Print E-mail
(5 votes)
Written by Chetankumar Akarte   
Monday, 16 July 2007

JavaScript Status Bar Left to right Text scroll

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...

Image

example:

Please download Source Code and test it ...

Source Code:

Download Source code for 'Status Bar Left to Right TextScroll'

Download


submit your Article, Tutorials or FAQs

Hello... if you are interested to submit your Article, Tutorials or FAQs on TechXcel.com - provides technical excellence... mail us at This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

Comments (0)Add Comment

Write comment
You must be logged in to a comment. Please register if you do not have an account yet.

Copyright 2007. All Rights Reserved.
busy




Reddit!Del.icio.us!Google!Live!Facebook!Slashdot!Netscape!Technorati!StumbleUpon!Spurl!Wists!Simpy!Newsvine!Blinklist!Furl!Fark!Blogmarks!Yahoo!Smarking!Netvouz!Shadows!
RawSugar!Ma.gnolia!PlugIM!Squidoo!BlogMemes!FeedMeLinks!BlinkBits!Tailrank!linkaGoGo!
Last Updated ( Monday, 16 July 2007 )
 

Who's Online

We have 1 guest online

User Login

PayPal Donation

Enter Amount:

Syndicate

TechXcel's Friends

Tutorials Garden
Wicolorz
pixel2life

Text Link Add

Statistics

Members: 262
News: 60
Web Links: 6
Visitors: 269789

Google Seach

Google AdSense

TechXcel Referrals

TechXcel's Sponcer...