Internet Close button processing
-
<script language="javascript" type="text/javascript"> window.onbeforeunload = function(){ return 'Your data will not be saved.'; }; </script> hai, currently i m using asp.net 2.0 (web application) here i would like to prompt the message to the user, where user, should not able to close the main window (IE). He must click only the application "Logout" button, so ,i would like to hide the close button or while user clicking the Internet Explorer(IE) close button he should prompt a message box (with only ok button) and again to his own application. how to achieve it? Thanks in advace, Karan
-
<script language="javascript" type="text/javascript"> window.onbeforeunload = function(){ return 'Your data will not be saved.'; }; </script> hai, currently i m using asp.net 2.0 (web application) here i would like to prompt the message to the user, where user, should not able to close the main window (IE). He must click only the application "Logout" button, so ,i would like to hide the close button or while user clicking the Internet Explorer(IE) close button he should prompt a message box (with only ok button) and again to his own application. how to achieve it? Thanks in advace, Karan
If people leaving the page without loging out will cause problems and you can tell them that they need to log out first, what will happen if they hit ALT+F4 to close or even if they just type in a new adress and leave your site that way? :) Javascript has an onUnload event, which is triggered when the browser is told to leave the page. You could use this event to trigger an auto-logoff for your site but I doubt it will handle cases where the browser is deliberately forced to close.
-
If people leaving the page without loging out will cause problems and you can tell them that they need to log out first, what will happen if they hit ALT+F4 to close or even if they just type in a new adress and leave your site that way? :) Javascript has an onUnload event, which is triggered when the browser is told to leave the page. You could use this event to trigger an auto-logoff for your site but I doubt it will handle cases where the browser is deliberately forced to close.
thank 4 u r reply sir. but while i m using that code, it prompting in all POSTBACK. i need only at the timeof IE close button clicks. Moreover, in my project there are nearly 100 pages. do i want to implement this code in all pages? help me. thanks in advance, Karan
-
thank 4 u r reply sir. but while i m using that code, it prompting in all POSTBACK. i need only at the timeof IE close button clicks. Moreover, in my project there are nearly 100 pages. do i want to implement this code in all pages? help me. thanks in advance, Karan
You will still need to handle it at the server side as well. Adding to what kstls said, what if they pull their power chord? What if some other program in the background causes a BSOD? You can't protect against that, and it will happen someday, so you had better be prepared..
-
You will still need to handle it at the server side as well. Adding to what kstls said, what if they pull their power chord? What if some other program in the background causes a BSOD? You can't protect against that, and it will happen someday, so you had better be prepared..
-
exactly you are right. but is there anyother way to force the user to do "LOGOUT" process?
-
exactly you are right. but is there anyother way to force the user to do "LOGOUT" process?
No. You can't prevent a user from clicking the close button on the browser or browser tab nor can you prevent them from navigating to another page.
only two letters away from being an asset
-
thank 4 u r reply sir. but while i m using that code, it prompting in all POSTBACK. i need only at the timeof IE close button clicks. Moreover, in my project there are nearly 100 pages. do i want to implement this code in all pages? help me. thanks in advance, Karan
Karan_TN wrote:
Moreover, in my project there are nearly 100 pages. do i want to implement this code in all pages?
Of course you don't. A properly designed application will separate this type of logic from the page. If your Javascript methods are in a separate file all you need to do is include the file reference. Better yet, if you are using master pages, include it in the master page and all content pages will have it also.
only two letters away from being an asset
-
Karan_TN wrote:
Moreover, in my project there are nearly 100 pages. do i want to implement this code in all pages?
Of course you don't. A properly designed application will separate this type of logic from the page. If your Javascript methods are in a separate file all you need to do is include the file reference. Better yet, if you are using master pages, include it in the master page and all content pages will have it also.
only two letters away from being an asset