[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Alert box OK Cancel same result

Posted on 2007-10-08
4
Medium Priority
?
669 Views
Last Modified: 2012-06-21
Here is the script
<script style="javascript">

function logOut()
{
    html = document.getElementsByTagName('html');
    html[0].style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)';
    if (confirm('Are you sure that you want to log out?')) { window.location.href='logout.php' } else { html[0].style.filter = ''};
}

</script>

By clicking the logout link the page is grayed out and an alert box come up asking if you want to log out, two buttons OK and Cancel, doesn't matter which one you click the result is the same you're loged out.

The question: how to fix it so when you click cancel you are actually not loged off.
0
Comment
Question by:gamebits
  • 2
  • 2
4 Comments
 
LVL 7

Expert Comment

by:DiscoNova
ID: 20038205
Umm... there must be something else than what you're showing us. The code seen is "correct"; it should (and does) not attempt to log you out if you click cancel (or close the shown dialog by pressing the "X" in the corner).
0
 
LVL 28

Author Comment

by:gamebits
ID: 20038240
Well you can try it yourself here

http://www.newgamebits.com/login.php

user: test
password: test

after you are loged in the logout link will appear on the left side menu
0
 
LVL 7

Accepted Solution

by:
DiscoNova earned 2000 total points
ID: 20038271
Ah, you have not overriden the default behaviour of the logout-link. Therefore; even when it asks if you wish to logout or not, no matter what, the link is followed anyway.

You need to change

  onclick="logOut()"

...into...

  onclick="logOut(); return false;"

...and it should work as you expect it to.
0
 
LVL 28

Author Comment

by:gamebits
ID: 20038295
Good job, I raised the points to the max for the extra effort, thanks.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question