HTML Goodies: Script Tip: Week 5

By Joe Burns

Hello, Script Tip Folk...

Let's start looking at a new script. This is a little more involved than the last one, so we should be able to really tear it apart and get a lot out of it.

Basically, here's what this script does:

  • Posts a dialogue box when a person enters the page.
  • The box has text on it that can be altered.
  • The box gives the user the opportunity to click OK to enter the page or Cancel not to enter the page.
  • If the user clicks OK, then the page loads as usual.
  • If the user clicks Cancel, then the script reloads the page the user was coming from.

The script is Copyright ) JemWeb 1997, but HTML Goodies has permission to use it to help you along with your JavaScripting.

That said, here's what it looks like:

<SCRIPT LANGUAGE="javascript">

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


How about that? All that functionality in such a small script!

We'll start tearing this pup apart by looking at the very first line in the script:

<SCRIPT LANGUAGE="javascript">

I am asked all the time if that LANGUAGE="javascript" item is actually needed (many people have found that simply writing SCRIPT will get the job done). The quick answer is yes, that LANGUAGE attribute is needed. Not all the time, but you should simply get into the habit of using it. The reason has to do with the fact that there are so many different types of scripts out there including JavaScript, Live Script, JScript, and VBScript. Each is quite similar and yet quite different.

By using the LANGUAGE attribute, you specifically lock in which script type you're using. It can be quite beneficial to the browser if the script you're using has commands found in different scripting languages.

So use it!

Next Week: What's A Function?

     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:

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!

Make a Comment

Loading Comments...

  • 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