/beyond/javascript/stips/article.php/3472071/HTML-Goodies-Script-Tip-Week-7.htm HTML Goodies: Script Tip: Week 7

HTML Goodies: Script Tip: Week 7

By Joe Burns

Hey, Tipmeisters...

This week we tear a little further into this fine script in an attempt to better understand it.

<SCRIPT LANGUAGE="javascript">

function JemWebCONFIRM()
{if (!confirm ("YOUR MESSAGE GOES HERE"))
history.go(-1);return " "}


Now, last time around we talked about the function, JemWebCONFIRM(), and what it did. This week we're going to talk about those parentheses that always seem to follow.

Believe it or not, those parentheses actually have a name. They're called an "instance." Here's a textbook-type definition:

The instance of a command is contained in parentheses immediately following the command. The instance contains information about what an object is to do or how a method is to be carried out.

Notice that this script has a few sets of parentheses. One set follows right after the function, the second surrounds the If statement, and the third surrounds the confirm command.

I can always keep my parentheses straight if I think of them like mathematical statements: Everything inside the parentheses gets done first. That means every open parenthesis needs a closer to go along with it.

But why are some parentheses empty, like the function, and others full of commands, like the confirm? It's because of what they do. Remember, the function is really a method. The method is carried out through a long series of commands. Remember that from last week? If the parentheses are empty, then the script looks for commands included inside of fancy parentheses { }. Those parentheses that have commands inside, run them.

Later in the Tips, we'll get into actually adding a name into the function parentheses so that you make it act upon a specific part of the page. But that's later...

Next Week: The Confirm Statement

     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