Javascript Scroll Title Bar
2003-01-19 20:31:49
Category: javascript:general
Description: Scroll a message across the title of your web browser.
Author: detour
Viewed: 6682
Rating: (23 votes)


<!-- scrolltitle.js by detour@metalshell.com -->
 
<!-- Scroll a message across the title bar forwards, -->
<!-- backwards and with a delay. -->
 
<!-- http://www.metalshell.com -->
 
<script language="javaScript">
var pos=0;
var str="Metalshell ";
// npos is used for forward scrolling
var npos=str.length;
// Normal upDate(). Other options upDateFW() and upDateWD()
setInterval("upDate()",300);
 
// Normal Scroll
function upDate()
{
  // Reset the title starting at pos
  document.title=str.substring(pos,str.length)+str.substring(0,pos);
  if(pos < str.length) pos++;
  else pos = 0;
}
 
// Scroll forward
function upDateFW()
{
  // Reset the title starting at pos
  document.title=str.substring(npos,str.length)+str.substring(0,npos);
  if(npos > 0) npos--;
  else npos = str.length;
}
 
// Scroll With Delay
var delay = 20;
function upDateWD()
{
  if(pos < str.length) {
    document.title=str.substring(pos,str.length)+str.substring(0,pos);
  }  else {
    if(pos > str.length+delay) {
      pos = 0;
    }
  }
  pos++;
}
</script>