SHARE
Facebook X Pinterest WhatsApp

HTML Goodies: Script Tip: Week 20

Written By
thumbnail
Joe Burns
Joe Burns
Jan 4, 2005

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):




<HTML>

<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?”,””)

document.write
(“<BODY BGCOLOR=” +color+ ” TEXT=” +txtcolor+ “>”)

defaultStatus=”Here’s your ” +color+ ” background and ”
+txtcolor+ ” text”

</SCRIPT>

Page text…

</HTML>


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
JavaScript Goodies!


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


Recommended for you...

The Revolutionary ES6 Rest and Spread Operators
Rob Gravelle
Aug 23, 2022
Ahead of Time (AOT) Compilation in Angular
Tariq Siddiqui
Aug 16, 2022
Converting a JavaScript Object to a String
Rob Gravelle
Aug 14, 2022
Understanding Primitive Type Coercion in JavaScript
Rob Gravelle
Jul 28, 2022
HTML Goodies Logo

The original home of HTML tutorials. HTMLGoodies is a website dedicated to publishing tutorials that cover every aspect of being a web developer. We cover programming and web development tutorials on languages and technologies such as HTML, JavaScript, and CSS. In addition, our articles cover web frameworks like Angular and React.JS, as well as popular Content Management Systems (CMS) that include WordPress, Drupal, and Joomla. Website development platforms like Shopify, Squarespace, and Wix are also featured. Topics related to solid web design and Internet Marketing also find a home on HTMLGoodies, as we discuss UX/UI Design, Search Engine Optimization (SEO), and web dev best practices.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.