To see each example:-
Click on a link below and load the example in this window.
Then to view the source code:-
Click the right mouse button over the window and then select "View Source" from the pop-up window.
If any graphics are used in the script:-
Click the right mouse button over each graphic and then select "Save Picture As" from the pop-up menu. (All of the graphics are included in the same directory as the javascript example.)
To go back to the Index:-
Click on the "Back" button at the top of your browser.
Add Commas Modifies a number by adding commas after every third digit. For example, 123456789 is converted to 123,456,789. The script example shows this script as used on numbers of various sizes.
Alert If you're just looking for a quick way to tell your visitor something, use this JavaScript alert! When they put their cursor on the link, they get the message in the form of a JavaScript alert!
Assorted Text Several different types of fancy assorted texts that are easy to incorporate into your web pages.
Auto Popup Window Automatically opens a small popup window and closes it after a specified time. Great for displaying important messages without forcing users to close multiple windows!
Banner Ads Need to rotate banner ads on your site? How about doing it in JavaScript! This simple little JavaScript will print out a random banner ad each time your page is viewed.
Check Sorter JavaScript can sort data based on any field of information. In this example, a checkbook register can be sorted by date, check number, check amount, or paid to person.
Confirm Entry This JavaScript askes you if you would like to continue. If you say "OK", it loads the page. If you click "CANCEL" (kinda like no) then it takes you back where you came from.
Confirm Alert Here is a JavaScript confirm message that has variable responses. Basically, the response they get depends on what the user enters.
Daily Tip Displays a Tip of the Day on your page. Some examples include tips on your site, quotes, computer tips, etc. Just update the tips on a monthly basis.
Dancing Links (Internet Explorer Only!) This little script will continuously change the highlighted link colors (visited and unvisited links) in Internet Explorer.
Date Message Displays your message on the appropriate day you indicate. For example, you can have it print messages on holidays, birthdays, or other dates that are important to you and your site's visitors!
Default Status Here's a neat way to put a message in the status bar on your page. It will stay there as the default message!
Description Layer (4.0+ browsers) Offer your visitors a quick description or more information about a link before they visit it. When they put their cursor over a link a layer will appear describing the link.
Editable Menu Allows you to modify the text value of a SELECT menu option. Upon selecting the option, if it is set as editable, a cursor will appear. To edit the option, simply type, and press enter when finished (To bring back the old value, just hit enter.) You can also define any option as "read-only".
Elastic Bullets Moves a series of images around the screen as if they were connected to the mouse cursor on a piece of elastic. In the demo, a series of small circular bullet icons are used. You could easily use any small images you want.
Fading Text This easy to configure text fader will Jazz up your website without the need for bulky Flash plugins or Applets. Texts may contain almost any HTML tags including links.
Favorite Banner Display banners while controlling how often they appear. Great for displaying a preferred banner over others!
Find In Page Allow your visitors to perform the same find in page search that Netscape and Internet Explorer browsers can perform on a page. They just enter a search term and hit enter. If the term is found on the page it is highlighted.
Flipping Messages When given a text box, JavaScript can flash messages in it. Similar to a scroll, but no scrolling is involved - otherwise it would be a scroll, not a game
Glow Text (Internet Explorer 5.5) Present text with an amazing glowing border. Automatically changes color, height, and width of message at a specified rate. Note: Text appears normal in all other browsers.
Hover Colors (Internet Explorer Only) Make the links on your site more exciting by changing the link text and background color when the link is being touched. Each link on your page can have a unique link and background color.
Image Description Offer your visitors a short description when they put their cursor on an image link. Give more information about what is offered at a site, if it is free or not, or anything else you think is important for them to know.
Info Box Put this useful little script on your page to display lots of information to your visitors quickly and effectively.
Info Stories Users can click on a headline and read a short description of the page, feature, or story. They can click the button to instantly be sent there! Great way to help your visitors get around your site!
Jitter Text (Version 4.0+ Browsers) The blink tag was good at getting your visitors attention, but how quickly it got annoying.... The newest attention-getter is Jitter Text! Just enter the text you want to use, and in version 4.0+ browser it will "jiggle" around the screen, like jello! And it is not annoying!
Link Message It's nice of you to show your visitors a little bit about a link before they follow it! When they put their cursor on a link, a description of the link appears on the status bar, rather than the URL!
Logo Orbit (IE Only) This orbiting 3-D message follows your mouse around the screen. The message, color and font are simple to modify!
Menu Message This script does a great job in presenting lots of information to your visitors without filling up your whole page. Each listing in the Pulldown Menu shows a different message in the text box!
Modify Array Demonstrates how to modify an array by adding elements to or remove elements from the array. Our example also includes validation to ensure that only valid elements are removed or that reasonable element indexes are added.
Mouse Trails A trail of cursors follow your cursor around the screen as you move the mouse. The image used here is transparent so the effect is subtle, but you could use any transparent image you want. Works in Internet Explorer and Netscape.
Mouse Banner Drags a text message, such as your site's name, around the screen behind the mouse cursor. Useful as an attention-grabber on the main page of your site.
Mouse Banner 2 Another way to display a banner behind the cursor. It's easy to change the font, size or color.
Name Alert JavaScript can personally great all the visitors to your web page! When they enter, they are asked their name, and then they are greeted!
Name Write Instead of alerting the user with "Welcome Name!" you can write it into your page. This is neat for users to suddenly be reading along and just stumble upon their own name!
Neon Text (IE Only) Display messages using this unique neon style method. (Netscape will only display the message normally.)
Phone Lookup Allows the user to enter their area code and phone number and have the modem dialup phone number for their area displayed. If their area code matches an area code as defined in the script, the appropriate dialup number is displayed. For all other area codes, an error message is displayed. Only supports one dialup number per area code, though.
Print Page Although JavaScript can't print a web page automatically, it can bring up the print prompt box just like the print button in the web browser does. The user can click "OK" to print the page. The script can be placed as a reminder to your visitors to print out important pages which contain their passwords, account info, order number, etc. The script can also be set to automatically remind them when the page loads.
Print Page Auto This automatic version of Print Page reminds them to print the page as soon as the page finishes loading. Useful when you want the visitor to print out their order page, or their account info page, or any other page with sensitive information.
Quick Alert Here is the simpliest and probably fastest JavaScript alert. As soon as the visitor's browser reads the JavaScript alert coding, the alert is displayed. This is even faster than the onLoad alert and even less coding!
Quote Of The Day A different quote is displayed each day of the month as the quote of the day. A breeze to customize!
Rainbow Text Displays your text in a multitude of rainbow colors. Definitely a visually appealing effect.
Random Name Creates a random male or female character name for use in a story, movie, play, etc.
Random Number Pass a range of numbers to this JavaScript function and it will return a random number within that range. For example, passing the range of [1, 158] would return a number such as 37, 141, 18, etc.
Random Jokes Ask your visitors a random joke or question from an array of questions. When they put their cursor over the question, a layer or alert message will appear with the answer.
Rotate Status Rotate two messages in the status bar with this script. Easy to add and modify!
Rotating Pulldown Menu Rotates site messages in a pulldown menu every few seconds. A good way to conserve screen space and even allows the user to simply click the pulldown menu to view all the messages at once.
Random Computer Quotes If you are a computer junkie, like me, then you probably will get a kick out of these random computer quotes all written by JavaScript.
Random Life Quotes If you want a quote to live by, check out this JavaScript life quotes generator.
Random Murphy's Laws I know you've heard of those witty little Murphy's Laws... Well, now you can have them on your web page! JavaScript can pick one and display it randomly each time your page is loaded!
Random Puns Use JavaScript to display one of many random puns.
Random Quips Of all the random message JavaScripts here at TJS, I probably like this one the most. It is hilarious! The JavaScript will randomly pick and write a quote to your web page.
Sentence Use JavaScript to write a random sentence to your web page. Unlike the other random scripts that pick one of 60, this script NEVER uses the same sentence twice! It picks a new subject, verb, and object combination for each page load.
Script Debugger Having trouble adding a JavaScript to your site? Just can't get things working? Add this short script to your site, and it will report to you JavaScript errors as they happen in a box on the screen. The idea is that you will see what the error is, and hopefully give you some ideas on how to fix it.
Show Link Info Let your visitor know exactly where a link will send them. This short script displays the domain the link points to as well as the filename of the page in the status bar at the bottom bar of the browser window.
Smart Marquee Changes the speed and direction of the marquee message based on mouse movement within Internet Explorer. Display's a static message in Netscape.
Split String The substring() function allows you to pull out any combination of characters from a string. In this example, an unformated date string such as 19990422 (which represents April 22, 1999) can be split up into 1999, 04, and 22. Each of these are separate variables that you can deal with independently in your scripts!
Status Bar Typing This short JavaScript will "type" a message in your browser's status bar.
Teletype Scroller Now you can type text across the screen and then scroll it off the page while it fades. Add as many messages as you need.
Text Highlighter Alternates the font color of each character in a line of text. Useful to catch the attention of your web site visitors. You may also customize the color and font of the text.
Text Rotater Automatically rotates a series of messages within a layer or div based on the user's browser. WC3 DOM Compatible.
Text Ripple The ripple is created by converting each sequential letter from lower case to upper case. The ripple speed can be also be changed.
Time Message This JavaScript is pretty interesting. It will dynamically (means it is different every time) write to the screen a message that depends on the time on the visitor's clock when they load the page.
Welcome Customize this Flash style intro to display a welcome message on your site.
Zen Take advice from the all powerful force of Zen. Zen will give you three phrases each time you click the button - the first phrase changes every hour, the second phrase changes every minute, and the last phrase changes every second.