Friday, March 29, 2024

HTML Goodies: Script Tip: Week 7

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 ” “}


</SCRIPT>





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



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

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Popular Articles

Featured