SHARE
Facebook X Pinterest WhatsApp

HTML Goodies: Script Tip: Week 8

Written By
thumbnail Joe Burns
Joe Burns
Jan 4, 2005

Hey, Tippy…

Okay, let’s talk about that confirm statement. Here’s the script once again:







<SCRIPT LANGUAGE=”javascript”>


function JemWebCONFIRM()

{if (!confirm (“YOUR MESSAGE GOES HERE”))
history.go(-1);return ” “}


</SCRIPT>






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:

confirm (“YOUR MESSAGE GOES HERE”)

…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: 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!

Recommended for you...

The Revolutionary ES6 Rest and Spread Operators
Rob Gravelle
Aug 23, 2022
Ahead of Time (AOT) Compilation in Angular
Tariq Siddiqui
Aug 16, 2022
Converting a JavaScript Object to a String
Rob Gravelle
Aug 14, 2022
Understanding Primitive Type Coercion in JavaScript
Rob Gravelle
Jul 28, 2022
HTML Goodies Logo

The original home of HTML tutorials. HTMLGoodies is a website dedicated to publishing tutorials that cover every aspect of being a web developer. We cover programming and web development tutorials on languages and technologies such as HTML, JavaScript, and CSS. In addition, our articles cover web frameworks like Angular and React.JS, as well as popular Content Management Systems (CMS) that include WordPress, Drupal, and Joomla. Website development platforms like Shopify, Squarespace, and Wix are also featured. Topics related to solid web design and Internet Marketing also find a home on HTMLGoodies, as we discuss UX/UI Design, Search Engine Optimization (SEO), and web dev best practices.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.