Friday, March 6, 2009

How to show 'Status Bar Message' in 4 different style by using JavaScript

I would like to share how to show 'Status Bar Message' in four different styles by using simple JavaScript. Its Very useful script for day-to-day coding. This is very helpful for biggeners also. Here's the code:

1. Static

<script language="JavaScript">
<!--
window.status = "My tutorial";
-->
</script>


2. Bouncing

<Script LANGUAGE="JavaScript">
<!--
var Message = "- My tutorial -";

var Leftspace = " ";
var Rightspace = " ";

var message1 = Leftspace + Message + Rightspace;
var dir = "left";
var speed = "100";

function bounce(){

if (dir == "left"){

var message2 = message1.substring(2,message1.length) + " ";
window.status = message2;
setTimeout("bounce()", speed);
message1 = message2;
if (message1.substring(0,1) == "-") dir="right";
}

else{

message2 = " " + message1.substring(0,message1.length-2);
window.status = message2;
setTimeout("bounce()", speed);
message1 = message2;
if (message1.substring(message1.length-1,message1.length) == "-") dir="left";
}

}

bounce();
// -->
</Script>


3. Scroll out

<script language="JavaScript">
<!--
var space = " ";
var speed = "100";
var pos = -20;
var msg = "My tutorial";
function Scroll()
{
window.status = msg.substring(pos, msg.length) + space;
pos++;
if (pos > msg.length + 10) pos = -20;
window.setTimeout("Scroll()", speed);

}
Scroll();
-->
</script>



4. Continuous scroll

<script language="JavaScript">
<!--
var space = " ";
var speed = "100";
var pos = 0;
var msg = "My tutorial";
function Scroll()
{
window.status = msg.substring(pos, msg.length) + space + msg.substring(0,pos);
pos++;
if (pos > msg.length) pos = 0;
window.setTimeout("Scroll()", speed);
}
Scroll();
-->
</script>

Related Posts :





0 comments :

Post a Comment

 

Copyright © 2009 - tutorialfeed.org