I am currently having some problems with a java script that I am developing.
– So far this has all been completed.
The javascript is geared to make a user aware that they are clicking the X (Close Button) A popup message comes up making the user aware of what they have done. To this they can either click O.K to continue closing the page or Cancel to stop closing the page.
The Problem
The next thing I want to do is add extra functions depending on the users choice. So basically I want to detect the users Choice, whether they clicked on O.K or Cancel so that I can assign Codes correspondingly
So for example in this project.
When the User clicks O.K to quit the program, this should be able to send a procedure to log-off from the system. What I need is to be able to detect that the user has clicked O.K so that I can do this.
So I want something Like
if event.returnValue = True
— (Call Log-Off Procedure Code)
The problem is I Cant get anything like that to work, below listed is the code that I am using, plus a few comments which state what I want to do more clearly in the code.
I want to thank anyone in advance for looking at the problem
[code=php]
<BODY onbeforeunload=”HandleOnClose”()>
<Script Language=”javascript”>
<!–
function HandleOnClose()
{
if (event.clientY < 0 )
{
event.returnValue = ‘You are going to leave the page press O.K to Log-Off Cancel to return to the page’;
— At this point I want something to say
— if event.returnValue=true then call log-off code
— Or is there any other way to do without using the returnValue
— statement.
}
}
//–>
</script>