Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    JavaScript


How To Show Confirmation Dialog When Leaving A Page

I would like to know how to display a confirmation message when a user attempts to navigate away from a page. For example, if a users clicks the X to close the window, or chooses another link from his favorites, I want to display a message that says something like "Are you sure you want to navigate away from this page, click OK to continue, or Cancel to remain on this page."

I noticed this on After you log in, when you try to close the window you get a confirmation dialog like I describe above. I didn't think this was possible to show a confirmation dialog using the onunload event, but I could be wrong.

View 3 Replies (Posted: 04-18-2006, 09:48 PM)

Sponsored Links:

Related Forum Messages For JavaScript category:
Popup - Confirmation When Leaving Page?
I'm trying to implement a basic popup window that asks the user if they really want to leave a page, similar to what would happen on this site if I tried to close the window half way through writing this message.I realise this is something that is generally frowned upon but I have good reason for wanting to do it.I have got it working by using the following code:

function confirm_exit(e) {
if(!e) e = window.event;
e.cancelBubble = true;


However, what I would really like to do is display the message whenever they leave the page, UNLESS they leave by clicking one of two links.(I've just realised that sounds like I might want to force them to click an advert or something!)The reason for using this is at the end of a booking process, where users can either confirm their booking or add further bookings before making the confirmation. (These would be the two possibilities that I would NOT like the popup message to display, the message in the pop up would just say something like 'Your booking is not yet confirmed, are you sure you wish to leave?).

Posted: Jul 1 10 at 8:17

View 1 Replies!   View Related
JQuery :: Show A Confirmation Dialog Before Submitting A Form Using Ajax Method?
I am using jquery ajax to delete a customer from a table. How would I show a confirmation box before submitting the form? I would preferably like to use jQuery's dialog.

This is my code:

type: "POST",
url: "delete/process.php",
data: "delcustomerid="+ delcustomerid,
success: refreshTable

Posted: Feb 18 10 at 18:33

View 2 Replies!   View Related
Tinymce Dont Show The Alert Leaving The Page?
I am using jquery with normal version (non-jquery).I am using jquery to get contents of the box like this

$(".submit").click(function() {
var text = tinyMCE.get('elm1').getContent();


But when i edit the content of the textarea and click submit and then leave the page.But it shows the alert box.I dont want it to come if the users have clicked the .submit after editing.

Posted: Aug 31 at 15:57

View 1 Replies!   View Related
LightBox Window Show Only Confirmation Page
I am developing a contact form and I have the form fully working but all I want is for when you fill out the contact form and submit it, a Lightbox window shows the confirmation page instead of it opening in the whole window. I have tried everything I can think of (I am a complete newbie with JS). The form is located here: [URL].

Posted: May 15th, 2010, 11:10 AM

View 2 Replies!   View Related
JQuery :: - Partial Page Update To Show Image And Delete Images On Confirmation?
I want to partially update page when i upload or delete the image. What i want is that when ever i browse.. to upload images i should automatically be able to refresh the images section after image upload is complete and also refresh the image section when i delete the image.Please advice how it can be done and if possible with a complete code example.or if some on can provide me with jQuery ASP.Net based control that will upload and show images also into the folder and database and give me option to delete the image later also all should be possible with partial page update as i have other control on the page

Posted: Nov 3 at 8:27

View 1 Replies!   View Related
JQuery :: Returning Value From Confirmation Dialog Using UI Dialog
I am using JQuery UI dialog to display a confirmation dialog when a button is clicked. I want to return 'true', when OK is clicked and false otherwise. Associating dialog open call in onClick (as given here, $dialog.dialog('open');) event does not serve the purpose. So, as a work around, I followed approach something similar to this: [URL]. There are two differences between this approach and mine (a) The example uses anchor tag and, (b) It does not uses JQuery UI dialog. I have modified the code given in the example link, but it does not work. I wonder what I am doing wrong. Is there any cheaper way to do this? Here is the code, all the css/js are referencing to JQuery CDN, so you should be able to copy the code to see the behavior.


Posted: Aug 24 10 at 20:45

View 1 Replies!   View Related
C# - Confirmation Dialog At Runtime In
I have a simple content management system that stores pages by Pagename and Version. After clicking on Save, my code (server side) checks for the existence of Pagename/Version.

If it exists I would like to display a confirmation dialog box, which asks the user to confirm whether or not the current Pagename/Version should be replaced.

What is the easiest way to accomplish this?

Posted: Aug 5 09 at 18:32

View 4 Replies!   View Related
Confirmation Dialog Does Not Appear In Firefox
I have created a button with a window.confirm() method but when I click on it in firefox the dialog box does not appear. It does however appear in all the other browsers

Posted: 10-26-2011, 11:13 AM

View 1 Replies!   View Related
JQuery :: Dialog Confirmation Before Submit
I'm using the jquery validation plugin and when all the fields of the form are correct I want to show a dialog that inform that the data will be submited, the problem is that the dialog just show for about 1/2 second and the form is submited, how can I do some kind of delay or pause before submit the form to show the confirmation.[code]

Posted: 28-Aug-2009

View 1 Replies!   View Related
Jquery :: Use A JQueryUI Dialog For Confirmation?
I'm trying to use the jQueryUI Dialog to get user confirmation before a database update, but I'm battling to see how I can tell what the user's choice on the dialog is, as all in samples I can find, both buttons just close the dialog, with no persistence of the chosen button. E.g. from the jQueryUI sample and docs:

buttons: {
'Deactivate the campaign': function () {


Posted: Feb 17 10 at 17:35

View 1 Replies!   View Related
JQuery :: - UI Dialog Confirmation Not Confirming?
I have this link on my page:

<a href='/Admin/Users/Delete/123' class='confirm'>Delete</a>
<div id="dialog-confirm" title="Delete this user?">
<span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>


The dialog opens like I should when I click the link. The only problem is that it doesn't wait for me to confirm or cancel, the dialog just pops up and it redirects to the url.

Posted: Jan 30 11 at 23:31

View 2 Replies!   View Related
Jquery :: Add A Confirmation Dialog To ASP MVC View?
I want to have a dialog box popup letting a user know of consequences when hitting the continue button, preferably styled better than a standard browser popup. I got jqdialog, a jquery plugin, and this was my solution: I have a view with the following HTML:

<form id="formSubmit" action="<%= ResolveUrl("~/Summary/Summary") %>" method="post">
<input type="button" name="summaryButton" id="bt-confirm" value="Continue »" />

and I've bound a click event to the button with some JQuery:


Posted: Feb 9 11 at 22:48

View 1 Replies!   View Related
JQuery :: Using A CAPTCHA Within UI Dialog Confirmation Box
I have a JQuery UI Dialog confirmation box that I need to make "extra sure" that the user really means it when they click "Confirm", so I think I want to use a CAPTCHA to capture this confirmation. Basically, disable the "Confirm" button in the popup until the entered text matches the CAPTCHA image.

how to do this, or even a better way to do this without resorting to a silly second "Are you really really really sure?" popup?

Posted: Dec 3 10 at 14:50

View 2 Replies!   View Related
JQuery :: Dynamic URL After Modal/dialog Confirmation
I have a table with edit and delete buttons on each row, I have managed to get modal dialogs working with the following code, the links that invoke the dialog each have a unique ID like so:

<a href="#" id="1234" class="dialog_link">Link text 1</a>
<a href="#" id="5678" class="dialog_link">Link text 2</a>

When the dialog is closed I need to call a PHP script to actually do the delete bit and I am stuck on that!

$(function() {
autoOpen: false,


Posted: 23-Jul-2010

View 7 Replies!   View Related
JQuery :: UI Multiple Delete Confirmation Dialog?
I have some chain of blog .I generate with php some topics ... exemple:

<div id="topic_1">
<div> some text</div>
<div><span class="delete">Delete</span></div>


Posted: 28-Sep-2009

View 4 Replies!   View Related
Implement A Confirmation Dialog For Critical Action?
I have Delete/Ban links on my site, that are used by admins to moderate the users and what they post. Since these links have such drastic consequences on the site's content I would want to have some sort of confirmation that would popup when one of the links is clicked. It should have some extra text explaining what's about to happen, and OK/Cancel buttons. So I have a link, for example like this:

<a href="ban.php?id=123" class="confirm_ban">Ban John</a>
<a href="delete.php?id=123" class="confirm_delete">Delete Post</a>

When this link is clicked, the code needs to be triggered. If OK is pressed, it goes to ban.php?id=123, if Cancel is pressed, it doesn't go anywhere. A simple JS dialog box, will do. Or if you have a link for a fancy jquery powered box, you can point me towards that also.

Posted: Jul 25 09 at 16:53

View 6 Replies!   View Related
JQuery :: Make Ui Dialog Box Look Like The Default Confirmation Box?
When a user needs to confirm something I use a simple confirmation box created with confirm, but some of my pages require "Yes" and "No" buttons instead of "Ok" and "Cancel" buttons, thus I use jQuery dialog on those pages. I want to make sure the styles of my message boxes are the same for my users across my entire application.How do I make my jQuery dialog boxes look exactly like the JavaScript confirm box? Surely I can change the CSS of the dialog box enough to make the two look the same... right?Confirmation box as generated by Grails in Firefox:Dialog box as generated by Grails in Firefox:So I want to completely remove the title bar from the dialog box, remove the rounded corners, change the striped background to grey, and change a bit of other coloring. I'm no CSS master, but I'm gonna try to muddle through it..

Posted: Oct 19 11 at 3:53

View 1 Replies!   View Related
Make Delete Button To Pop Up Confirmation Dialog Box?
Trying to get a delete confirm dialog box to open when you click on the button.

Posted: 05-12-2011, 08:41 PM

View 3 Replies!   View Related
Make Delete Button Pop Up A Confirmation Dialog Box?
Here's the code. what am I missing to make this work?

@if (Model.Layer.Id > 0){
<div style="float: left; padding-left: 14px;">
@using (Html.BeginForm("Delete", "Layer", new { layerId = Model.Layer.Id, subAccountId =


Posted: 05-18-2011, 09:46 PM

View 2 Replies!   View Related
JQuery :: Wait For Confirmation Dialog Return Value
I have the following jQuery code:


I need to make the call to myBean.delete after the user confirms the dialog, but it just continues and makes the call with the dialog still open. How can I make the dialog to return a synchronized value? So the commandLink can know wether to execute the action or not. I know it can use callbacks, but callbacks is not an option since the commandLink is waiting for the result to decide to execute the action, and if I use callbacks I will need to make a direct call to the which would make an infinite loop. Even thought, thinking again there could be a way to use callbacks but how could I send to the dialog which callback to call when it's done.

Posted: Nov 28 11 at 0:41

View 2 Replies!   View Related
Jquery :: Css - Change The Button Size In The Ui Confirmation Dialog?
My code is below.i need to change the button size in the ok and cancel in the button.

<div style="font-size: medium" id="dialog" title="Confirmation Required">
Story Will Be Deleted??
<script type="text/javascript">
$(document).ready(function() {

Posted: Mar 22 11 at 3:39

View 2 Replies!   View Related
Capturing Result Of Window.onbeforeunload Confirmation Dialog
Is there a way to capture to result of the window.onbeforeunload confirmation dialog like the one below from stackoverflow (this happens when leaving the 'Ask Question' page without posting the question)? This is how it appears in Chrome, I believe it's slightly different in other browsers, but you always have some form of yes/no buttons. Presumably if they're still on the offending page after the event has been triggered they chose to stay and you could probably figure this out by watching the sequence of js. However I would like to know how to determine if they clicked "Leave this page"? I've implemented this like below:


I'm essentially trying to implement a Gmail like drafting implementation, wherein if a user leaves a page with a form they've made changes to without saving they're warmed with a similar dialog. If they choose to discard they're changes and leave the page, I need to clean up some temporary records from the database (I'm thinking an ajax call, or simply submitting the form with a delete flag) then sending them on their way. My question also relates to: jQuery ajax call in onunload handler firing AFTER getting the page on a manual refresh. How do I guarantee onunload happens first?

Posted: Mar 23 at 0:43

View 1 Replies!   View Related
Jquery :: Dialog Box Not Showing On The Second Click Of The Confirmation Box Ok Button?
I have a button named submit, when i click this button i got a confirmation box. If i click the Ok button on the confirmation box i got a dialog box. But if i cancel this dialog box and try to do this once again i was not able to see the dialog box.HTML looks like this

<input type="submit" id="btnSubmit" class="button" value="<%= OsflAdminResources.Text_Users_Permanently_Delete_Selected_Users %>"
onclick="return validate();" />


Posted: May 11 11 at 9:34

View 3 Replies!   View Related
JQuery :: Change Button Labels In UI Confirmation Dialog Box?
I would like to use jQuery's UI dialog box for confirmation:

$( "#dialog-confirm" ).dialog({
buttons: {
"Button One": function() {
$( this ).dialog( "close" );
"Button Two": function() {

But I would like to change the button labels based on condition:


Can't seem to be able to combine the two...

Posted: Jun 19 at 23:19

View 1 Replies!   View Related
Copyright 2005-08, All rights reserved