Nutic
Nutic

Reputation: 1437

Logout confirm dialog

I have redirect to logout.php

<a class="menu_button" href="logout.php">Logout</a>

On logout.php I just destroy session and redirect user back to login.

What I need is that when user click on menu_button Logout, to display dialog box asking him to confirm that he wants to logout.

I know I can do it via php new page, but think this is more elegant.

I have this:

<a class="menu_button" href="logout.php" onClick="return confirm('Sure to logout?');">Logout</a>

But browser popup window is just ugly..

EDIT:

I used this, and it's not working....

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/blitzer/jquery-ui.css" type="text/css" />
<script src="jquery/js/jquery.easy-confirm-dialog.js"></script>
<script>
$(".customDialog").easyconfirm({dialog: $("#question")});
</script>

body

<a href="?confirm=true" class="customDialog">Test with custom confirm dialog</a>
  <div class="dialog" id="question"><img src="question.png" alt="" />Do you want to continue?</div>

Upvotes: 2

Views: 5869

Answers (2)

Bart Platak
Bart Platak

Reputation: 4475

Are you with familiar jQuery (and more specifically jQuery ui? They can allow you to create fairly good looking dialogs (by which I mean you can do pretty much anything with them that you can with your page - in an easy way).

I would also recommend jquery easy confirmation dialogs plugin.

Upvotes: 1

dmi3y
dmi3y

Reputation: 3532

You may adapt jQuery UI dialog. It is very easy to use. Actually, try http://jqueryui.com/dialog/#modal-confirmation

Upvotes: 1

Related Questions