Introduction
With the help of JavaScript we can add our favorite message with marquee effect. For that we create an object with a constructor, a special type of function that prepares a new object for use by initializing the memory it takes up. Objects are created by applying the new operator to their constructors. This operator causes the constructor to which it is applied to create a brand-new object, and the nature of the object that is created is determined by the particular constructor that is invoked. Here we creates a new setStatusmessage() object and places a reference to it in the variable scroll. Here we define function function scroller() which scroll our message. Here first we add blank spaces before message and reduce one space per loop. And refresh status message by setTimeout ('scroller()',scroll.delay). After shift all message by scroll.out = scroll.msg.substring(-scroll.pos,scroll.msg.length). Then we make message again ready to scroll.
Source Code
< SCRIPT language=JavaScript>
var scroll = new setStatusmessage()
function setStatusmessage() {
this.msg = "This is Scrolling Message...!!!"
this.out = " "
this.pos = 100 // how wide is the scroller?
this.delay = 50 // milliseconds between shifts
this.i = 0
}
function scroller() {
for (scroll.i = 0; scroll.i < scroll.pos; scroll.i++) {
scroll.out += " "
}
if (scroll.pos >= 0)
scroll.out += scroll.msg
else scroll.out = scroll.msg.substring(-scroll.pos,scroll.msg.length)
window.status = scroll.out
scroll.out = " "
scroll.pos--
if (scroll.pos < -(scroll.msg.length)) {
scroll.pos = 100
}
setTimeout ('scroller()',scroll.delay)
}
scroller()
< /SCRIPT>
Summary
This artical gives an idea to add Message Marquee at Status Bar of Web Browser