|
|
|
|
Like this code?
Show the author your appreciation.
|
|
| |
In this example I show how to add a bouncing message at the status bar of the browser.
Define the next variables :
o data - contains a message to be displayed
o limit - bounce limit
o message1
o direction
o speed
The function bounce() contains an if-else condition that bounces the message left or right.
To shift the message left we add two spaces to message1 and assign the value to message2 :
|
message2=message1.substring(2,message1.length)+" "; | |
and display it at the status bar by
We refresh the message with
| | setTimeout("bounce();",speed); | |
and repeat the process.
As we reach ‘*’
| | if (message1.substring(0,1) == "*" ) direction="right"; | |
we set the direction to the right so the else condition is satisfied and we subtract two spaces from message1 and assign the value to message2 :
| | message2=" "+message1.substring(0,message1.length-2); | |
and display it at the status bar with :
And repeat process to ‘*’ and set direction to the left :
| | if (message1.substring(message1.length-1,message1.length) == "*") direction="left"; | |
in this way we can bounce our message at the status bar
Full Code
| <SCRIPT language=JavaScript type="text/javascript">
<!--
var data = " My Bouncing Message ... !!! "; // Message to be display
var limit=" "; // define bounce limit
var message1=limit+'*'+data+'*'+limit;
var direction = "left";
var speed = 75;
function bounce()
{
if (direction == "left")
{
message2=message1.substring(2,message1.length)+" ";
window.status=message2;
setTimeout("bounce();",speed);
message1=message2;
if (message1.substring(0,1) == "*")
direction="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) == "*")
direction="left";
}
}
bounce()
// -->
</SCRIPT> | | |
|
| Message Marquee at Status Bar Categories : Java Script, HTML, Browsers | | | Javascript Background Scroller Categories : Java Script, CSS, HTML | | | hick Categories : HTML, Java Script | | | Get your browser details using javascript Categories : Java Script, Beginner Guides, Browsers | | | Clock at Status Bar Categories : Java Script, HTML, Date Time | | | Prevent Right Mouse steal your graphics Categories : HTML, Java Script, Security | | | complete simply working javascript password generator file. Use letter, vowels, consonants (uppercase and lowercase) arrays to create a really random and secure password.
improved security using time functions to initialize random number generator. Categories : Java Script, HTML, Security, Authentication, Strings | | | Table editable dynamic form with edit + selection (select / option) + checkbox.
Categories : Java Script, DHTML, User Interface, CSS, HTML | | | Builds JavaScript that updates the contents of one selector based on another. Categories : HTML, Java Script, PHP, Complete Programs, General | | | Javascript Color Picker Categories : Java Script, Colors, HTML | | | Mordern Peroidic Table - Science Categories : Java Script, HTML, Charts and Graphs | | | Cool tool tip Categories : Java Script, HTML, Web Design | | | Java Script Based Navigation Categories : HTML, Java Script, Navigation | | | Unobtrusive javascript for maintaining scrollable layer state Categories : DHTML, Java Script, HTML | | | Higly Customizable Javascript Calendar Script Categories : Java Script, Calendar, Date Time, HTML, CSS | |
|
|