Hey, Tipmeisters…
This week we tear a little further into this fine script in an attempt to better understand it.
<SCRIPT LANGUAGE=”javascript”>
|
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:
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
JavaScript Goodies!
on your Web pages here!