|
|
|
|
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 | | | Java Script Based Navigation Categories : HTML, Java Script, Navigation | | | Builds JavaScript that updates the contents of one selector based on another. Categories : HTML, Java Script, PHP, Complete Programs, General | | | Javascript Background Scroller Categories : Java Script, CSS, HTML | | | How to create <SELECT> menues that change on the fly according to other <SELECT> menues on the page? Categories : Java Script, HTML | | | Prevent Right Mouse steal your graphics Categories : HTML, Java Script, Security | | | Conditional Check - a script that allows a user to submit a form only if the user check a checkbox. Categories : HTML, Java Script, Form Processing, Beginner Guides | | | Javascript linked dropdowns Categories : Java Script, HTML, Classes and Objects | | | Javascript animated menu items Categories : DHTML, CSS, Java Script, HTML | | | Page Loading Message shown during the time your site's page is being loaded. Categories : HTML, CSS, Java Script | | | 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 | | | Get your browser details using javascript Categories : Java Script, Beginner Guides, Browsers | | | Bookmarklets are simple tools that extend the surf and
search capabilities of Netscape and Explorer web browsers. Categories : Java Script, HTML, General | | | Cool tool tip Categories : Java Script, HTML, Web Design | | | How to get the Focus (Cursor) into a Form-Element. Categories : HTML, Java Script | |
|
|
|