Assignment 13 - A Possible Answer

You actually have to hit cancel to be reading this. Here's how I did it.

In the HEAD commands, I put this:

<SCRIPT LANGAUAGE="javascript">

function wannago()

if (confirm
 ("Are you sure you want to enter HTML Goodies?") )

alert("Good choice");


alert("Then you'll stay right here");



...and the <BODY> command looks like this:

<BODY onLoad="wannago()">

The process was actually quite simple:

  • The function was created by copying and pasting the script between the <HEAD> commands, adding the function statement, and then surrounding the entire code with two more fancy parantheses. It makes for a lot of the litte buggers, but they're all needed.

  • The command "defaultStatus='Chicken!';" was added in the else section to get the text in the status bar.

  • The function is triggered by an onLoad Event Handler in the BODY command.

  • If you wanted to get fancy and have the page open in a new window, you only had to change out two words. Exchange "parent.location" with "" and you're done.

Close this window to return to JavaScript Primer #1