Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function NewsTicker()
- {
- this.container = null;
- this.text = "";
- this.index = 0;
- this.len = 0;
- this.othercolor = false;
- }
- NewsTicker.prototype.init = function()
- {
- div = document.getElementById("newsticker");
- if(div)
- {
- this.container = div;
- this.text = div.innerHTML;
- }
- }
- NewsTicker.prototype.loop = function()
- {
- if(this.container == null)
- {
- this.init();
- window.setTimeout("newsticker.loop()","250");
- }
- else
- {
- this.index++;
- if(this.index>=this.text.length)
- {
- this.index = 0;
- this.othercolor = !this.othercolor;
- }
- if(this.othercolor)
- this.container.innerHTML = "<font color=#00ff00>"+this.text.substring(this.index)+"</font> "+this.text.substring(0,this.index);
- else
- this.container.innerHTML = this.text.substring(this.index)+" <font color=#00ff00>"+this.text.substring(0,this.index)+"</font>";
- window.setTimeout("newsticker.loop()","125");
- }
- }
- window.newsticker = new NewsTicker();
- window.newsticker.loop();
Advertisement
Add Comment
Please, Sign In to add comment