DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

How To Display Confirm

  • submit to reddit
        The JavaScript confirm function is very similar to the JavaScript alert function. A small dialogue box pops up and appears in front of the web page currently in focus. The confirm box is different from the alert box. It supplies the user with a choice; they can either press OK to confirm the popup's message or they can press cancel and not agree to the popup's request.

Confirm Example
<script type="text/javascript">
function confirmation() {
	var answer = confirm("Leave")
	if (answer){
		alert("Bye bye!")
		window.location = "";
		alert("Thanks for sticking around!")
<input type="button" onclick="confirmation()" value="Leave">

<a href=""><strong>Spring Framework</strong></a>