Show DevBest Javascript Moving Title!

xDan

New Member
Dec 24, 2013
9
2
Code:
<script type="text/javascript">
<!--//
function tb9_makeArray(n){
    this.length = n;
    return this.length;
}
tb9_messages = new tb9_makeArray(4);
tb9_messages[0] = " Hello ";
tb9_messages[1] = "This";
tb9_messages[2] = "is";
tb9_messages[3] = "a";
tb9_messages[4] = "Title";

tb9_rptType = 'infinite';
tb9_rptNbr = 5;
tb9_speed = 75;
tb9_delay = 2000;
var tb9_counter=1;
var tb9_currMsg=0;
var tb9_timerID = null
var tb9_bannerRunning = false
var tb9_state = ""
tb9_clearState()
function tb9_stopBanner() {   
    if (tb9_bannerRunning)       
    clearTimeout(tb9_timerID)   
    tb9_timerRunning = false
}
function tb9_startBanner() {   
    tb9_stopBanner()   
    tb9_showBanner()
}
function tb9_clearState() {   
    tb9_state = ""   
    for (var i = 0; i < tb9_messages[tb9_currMsg].length; ++i) {       
        tb9_state += "0"   
    }
}
function tb9_showBanner() {   
if (tb9_getString()) {       
    tb9_currMsg++       
    if (tb9_messages.length <= tb9_currMsg)    {       
        if ((tb9_rptType == 'finite') && (tb9_counter==tb9_rptNbr)){
            tb9_stopBanner();
            return;
        }
        tb9_counter++;
        tb9_currMsg=0;
    }
    tb9_clearState()       
    tb9_timerID = setTimeout("tb9_showBanner()", tb9_delay)   
}
else {       
    var tb9_str = ""       
for (var j = 0; j < tb9_state.length; ++j) {           
    tb9_str += (tb9_state.charAt(j) == "1") ? tb9_messages[tb9_currMsg].charAt(j) : "___"       
}       
document.title = tb9_str       
tb9_timerID = setTimeout("tb9_showBanner()", tb9_speed)   
}
}
function tb9_getString() {   
    var full = true   
    for (var j = 0; j < tb9_state.length; ++j) {       
        if (tb9_state.charAt(j) == 0)           
            full = false   
        }   
    if (full) return true   
    while (1) {       
        var num = tb9_getRandom(tb9_messages[tb9_currMsg].length)       
        if (tb9_state.charAt(num) == "0")           
            break
    }   
    tb9_state = tb9_state.substring(0, num) + "1" + tb9_state.substring(num + 1, tb9_state.length)   
    return false
}
function tb9_getRandom(max) {   
    var now = new Date()       
    var num = now.getTime() * now.getSeconds() * Math.random()   
    return num % max
}
tb9_startBanner()
</script>


Hey guys, i didn't make this but i thought it looks cool so ill share it with you guys! :)
Paste the code just above your <body> tag
Incase you didn't know already it's a script which allows you to have a moving title, ENJOY! ;) :rasta:
 

GohanSSJ

Ya.
Feb 18, 2013
281
30
I may just make a demo site then if people don't feel like uploading screen-shots because you do need to provide screen-shots or a demo.

So please do so or I'll just make one.
 

Users who are viewing this thread

Top