HTML Goodies: Script Tip: Week 20

By Joe Burns

Trip! I mean, Tip!

This script offers one more little ditty that you need to be aware of. It's a lot like a JavaScript Event Handler, but not quite. Here's the script again. When you look at the example, check out the status bar.

Once again, the looks like this (although I've put things on different lines to keep this page format correct, remember that everything must be on one line):

<TITLE>title text</TITLE>

<SCRIPT LANGUAGE="javascript">
var color = prompt
("What color would you like the page background to be","")
var txtcolor = prompt
("What color would you like the text to be?","")
("<BODY BGCOLOR=" +color+ " TEXT=" +txtcolor+ ">")
defaultStatus="Here's your " +color+ " background and "
+txtcolor+ " text"

Page text...


Click Here To See The Script In Action

The text that showed up in the status bar was placed there by this line:

defaultStatus="Here's your " +color+ " background and " +txtcolor+ " text"

Up until now you might have been used to putting text into the status by a JavaScript Event Handler, then window.status. Well, you don't always have such an event to attach a window.status statement to. This is one of those cases.

So, the people who came up with JavaScript wrote this little ditty into the code: "defaultStatus = "

That little number can be plopped basically anywhere and whatever follows it shows up in the status bar. Super cool, huh?

You can see that I'm using a few returns, the things inside of the plus signs, to get the prompt variables in the mix. It just looks good to personalize the text.

Use it in good health!

Next Week: New Script! A Fancy Guestbook

     Do YOU have a Script Tip you'd like to share? How about suggesting a Script Tip to write about? I'd love to hear it. Write me at: jburns@htmlgoodies.com.

Learn to write your own JavaScripts with the
HTML Goodies 30-Step Primer Series
and take the knowledge home with you in
JavaScript Goodies!

You can find many other uses for JavaScript
on your Web pages here!

  • Web Development Newsletter Signup

    Invalid email
    You have successfuly registered to our newsletter.
Thanks for your registration, follow us on our social networks to keep up-to-date