HTML Goodies: Script Tip: Week 8
Okay, let's talk about that confirm statement. Here's the script once again:
Confirm. Verb. The act of verifying a statement. That's the point of the confirm statement. Take a moment and look again at what the script does. Try clicking here.
See that gray box that popped up? That's what the confirm command does. It posts that box with two choices, OK and CANCEL. The OK button is the default. If you click it, then you confirm the command and you get to go to the page you originally wanted to go to.
Clicking CANCEL is another matter. The CANCEL button can have a few different functions. If you have nothing more than this:
...then the CANCEL button does just that: It cancels the effect. The box goes away, but your user still goes to the page as the link has already occurred and the page has started to load. Remember: This script is sitting on the page we wanted to go to.
But that CANCEL default is not what's happening here. Here the author has set it up so that when you click Cancel, the browser goes back one page to the original page you came from.
It probably has something to do with that history.go(-1) thing.
Next Week: That history.go(-1) Thing
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: firstname.lastname@example.org.
HTML Goodies 30-Step Primer Series
and take the knowledge home with you in
on your Web pages here!