Click here to Skip to main content
15,896,915 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a small requirement..

if the user dint sign off or log off then he try's to close the browser IE clicking on 'X' (top right of IE or Firefox browser ) then i need to ask a conformation message like "Are you sure you want to close ?" ...
I am using Master page in my application and i tried the event : "window.onbeforeunload " in my master page its works fine, shows an alert(conformation) message. but if i press back button on the browser(IE on IE or Firefox) then also its firing(but it should not) is there any way to full fill my requirement ..I hope i had explained u clearly...if not pl z let me know........



what i mean to say is.. if the Session("USerid") is active or if it contains any value ie.
Session("USerid")="XXX"
at that moment if user trys to close the browse(click in 'X'/Close button browser either IE or Firefox ) it should give prompt a message "are u sure do u want to close?"..
Posted
Comments
LanFanNinja 7-Feb-12 0:30am    
Not that it matters to you but I truly hate these kinds of popups!

call button log off event to this code

XML
<script type="text/javascript">

     window.onbeforeunload= function(){

   if((window.event.clientX<0) || (window.event.clientY<0))

       {
         document.getElementById('<%= btnLogoff.ClientID%>').click();
       }

   };

    </script>
 
Share this answer
 
Comments
Veera anil 7-Feb-12 0:41am    
its also firing when i press back button on the browser..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900