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. C#
  4. How to catch browser close

How to catch browser close

Scheduled Pinned Locked Moved C#
5 Posts 2 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.
  • D Offline
    D Offline
    dataminers
    wrote on last edited by
    #1

    How to catch browser close? I try following script but, it's accept postback events... <script type="text/javascript"> window.onbeforeunload = function() { window.open('Logout.html'); } </script> Best Regards...

    D 1 Reply Last reply
    0
    • D dataminers

      How to catch browser close? I try following script but, it's accept postback events... <script type="text/javascript"> window.onbeforeunload = function() { window.open('Logout.html'); } </script> Best Regards...

      D Offline
      D Offline
      Deresen
      wrote on last edited by
      #2

      First: this is no javascript forum Second: search on google for an anwser Third: here you go:

      <head>

      <script language="javascript">
      <!--
      function LoadMe()
      {
      self.close();
      }
      // -->
      </script>
      </head>

      <body onload="LoadMe()">
      <div align="center">

      <a href="javascript:window.close()">Close</a>

      </div>
      </body>

      D 1 Reply Last reply
      0
      • D Deresen

        First: this is no javascript forum Second: search on google for an anwser Third: here you go:

        <head>

        <script language="javascript">
        <!--
        function LoadMe()
        {
        self.close();
        }
        // -->
        </script>
        </head>

        <body onload="LoadMe()">
        <div align="center">

        <a href="javascript:window.close()">Close</a>

        </div>
        </body>

        D Offline
        D Offline
        dataminers
        wrote on last edited by
        #3

        My question is "How to catch browser close ?". It's mean how can I detect press close button on the browser. Thanks...

        D 1 Reply Last reply
        0
        • D dataminers

          My question is "How to catch browser close ?". It's mean how can I detect press close button on the browser. Thanks...

          D Offline
          D Offline
          Deresen
          wrote on last edited by
          #4

          If your question is 'how can I detect press close button on the browser' you should question that in stead of 'how to catch browser close'. And maybe I've allready given you the anwser: <body onload="LoadMe()"> I even wrote an implementation for you, but you're probably not interested in that.

          D 1 Reply Last reply
          0
          • D Deresen

            If your question is 'how can I detect press close button on the browser' you should question that in stead of 'how to catch browser close'. And maybe I've allready given you the anwser: <body onload="LoadMe()"> I even wrote an implementation for you, but you're probably not interested in that.

            D Offline
            D Offline
            dataminers
            wrote on last edited by
            #5

            Thanks for care Deresen. But I try following script but, it's accept postback events... <script type="text/javascript"> window.onbeforeunload = function() { window.open('Logout.html'); } </script> I must be foud diffirentation between browser close and "Postback". Thanks again...

            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