Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

Close button of the browser

Hi,
I need to know when the user will click the close button of the browser..
Pls. help
0
kulsmadya
Asked:
kulsmadya
  • 2
  • 2
  • 2
  • +5
1 Solution
 
edemcsCommented:
what specifically for?  If you want to run a function when the page is unloaded, you could you the OnUnload attribute in the Body tag.
0
 
nimaigCommented:
But remember OnUnload event is called the user closes the browser as well as when the page is refreshed  or the user moves to another page leaving the current page.
0
 
kulsmadyaAuthor Commented:
I need to call the function when the user will click close button of the browser.

scenario is: if the user is logged in into the website. & if he doesnt logout & clicks the close button of the browser, i need to trap the event.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
dij8Commented:
It can't be done.  The only option is onunload.  And that is not what you are after.

Closing the browser (all instances) will kill any sessions so that may solve the problem you have regarding logging out.
0
 
nimaigCommented:
It is not possible ..........
0
 
kulsmadyaAuthor Commented:
so what would be the work arround??
0
 
dij8Commented:
Educate the people using your site to use the log-out button that you also include in your page.  And that is the ONLY solution.
0
 
edemcsCommented:
Here is the solution:

<body onLoad="closing=true" onUnload="if (closing) window.open('thanksForVisiting.html','newwin');">

<a href="nextpage.htm" onClick="closing=false">Click to go to another page..</a>

When links are clicked, set the closing variable = false.  If a link isn't clicked and the page unloads, that probably means that the user is closing the browser!  This should definitely work.

Hope this helps!
0
 
daniel_cCommented:
0
 
kamcheungonCommented:
Another alternative, works with older browser:

In your main window:
<html>
<head>
<title></title>
<script>
<!--
var WinMon;

function OpenMonitor () {
     WinMon = window.open ('monitor.html','monitor','width=100,height=100');
     WinMon.opener = window;
     
     WinMon.OpenerAlert ();
}

function OpenerCheck () {
     alert (self.screenTop);
     if (WinMon) {
          WinMon.OpenerAlert ();
     }
}
//-->
</script>
</head>
<body onLoad="OpenMonitor ()" onUnload="OpenerCheck ();">
</body>
</html>


In the pop up "monitor.html":
<html>
<head>
<title></title>
<script>
<!--
var TimeoutID;
function CheckOpener () {
     if (opener.closed) {
          alert ("Opener is Closed");
          clearTimeout (TimeoutID);
     }
}

function OpenerAlert () {
     TimeoutID = setTimeout ("CheckOpener()", 100);
}
//-->
</script>
</head>
<body>
</body>
</html>



0
 
MoondancerCommented:
This question appears to have been abandoned. All your open questions today are at the bottom.   Your options are:
 
1.  Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3.  Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4.  Delete the question. Again, you must tell the other participants why you wish to do this.

For special handling needs, please post a zero point question in the link below, include the question QID/link.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click this Help Desk link for Member Guidelines, Member Agreement and the Question/Answer process:  Click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues.
http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp


PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:
 
Please leave any comments regarding this question here on closing recommendations if this item remains inactive another three days.
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange
 
P.S.  For year 2000 question, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.

--------------------------------------------------------------------------------------------------------------------------
http://www.experts-exchange.com/jsp/qShow.jsp?qid=11853299
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20118299
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20136303
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20136304
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20144419

 
0
 
NetminderCommented:
Force-accepted by
Netminder
CS Moderator
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
  • 2
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now