Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Internet Close button processing

Internet Close button processing

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpjavascriptasp-nettoolstutorial
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Karan_TN
    wrote on last edited by
    #1

    <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

    K 1 Reply Last reply
    0
    • K Karan_TN

      <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

      K Offline
      K Offline
      kstls
      wrote on last edited by
      #2

      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.

      K 1 Reply Last reply
      0
      • K kstls

        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.

        K Offline
        K Offline
        Karan_TN
        wrote on last edited by
        #3

        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

        L N 2 Replies Last reply
        0
        • K Karan_TN

          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

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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..

          K 1 Reply Last reply
          0
          • L Lost User

            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..

            K Offline
            K Offline
            Karan_TN
            wrote on last edited by
            #5

            exactly you are right. but is there anyother way to force the user to do "LOGOUT" process?

            L N 2 Replies Last reply
            0
            • K Karan_TN

              exactly you are right. but is there anyother way to force the user to do "LOGOUT" process?

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              I don't know mate, I'm not a web dev, sorry :(

              1 Reply Last reply
              0
              • K Karan_TN

                exactly you are right. but is there anyother way to force the user to do "LOGOUT" process?

                N Offline
                N Offline
                Not Active
                wrote on last edited by
                #7

                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

                1 Reply Last reply
                0
                • K Karan_TN

                  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

                  N Offline
                  N Offline
                  Not Active
                  wrote on last edited by
                  #8

                  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

                  K 1 Reply Last reply
                  0
                  • N Not Active

                    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

                    K Offline
                    K Offline
                    Karan_TN
                    wrote on last edited by
                    #9

                    thanks for your kind replies

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups