Continued from page 1
To change
text in
status bar of a browser window, we just change
"status" member of
"window" object, which represents our entire browser window:
window.status = "This is some text";
----------------------------------------------- Using an input box to get text from
user -----------------------------------------------
Just like in traditional windows applications, we can use an input box to get some text input from
user. The "prompt" function is all we need:
var name = prompt("What is your name?"); document.write("Hello " + name);
The prompt function accepts just one argument (the title of
input box), and returns
value entered into
text box. In
example above, we get
users name and store it in
"name" variable. We then use
"document.write" function to output their name into
browser window.
----------------------------------------------- Using a message box to display text to
user -----------------------------------------------
We can display a message box containing an OK button. These are great when you want to let
user know what is happening during their time on a particular page. We can use a message box to display
"name" variable from our previous example:
var name = prompt("What is your name?"); alert("Your name is: " + name);
The "alert" function takes one argument, which is
text to display inside of
message box.
----------------------------------------------- Changing
title of
browser window -----------------------------------------------
To change
title of our web browser's window, we simply modify
"document.title" variable, like this:
document.title = "My new title";
One bad thing about
"document.title" variable is that we can only manipulate it in Microsoft Internet Explorer. Netscape's implementation of JavaScript doesn't allow us to modify it.
----------------------------------------------- In Closing -----------------------------------------------
As you can see from
examples in this article, JavaScript is a powerful scripting language that we can use to enhance our visitors experience with our site. You shouldn't use JavaScript too much, however, because in some cases it can annoy your visitors and send them packing before your site even loads!

Mitchell Harper is the founder of http://www.devarticles.com. DevArticles provides its visitors with useful, informative articles on ASP, PHP, and .NET, as well as heaps of tips and tricks that you wont find anywhere else! To see what it's all about, visit devArticles right now at http://www.devarticles.com