Solved

Close button of the browser

Posted on 2001-06-15
12
186 Views
Last Modified: 2012-05-04
Hi,
I need to know when the user will click the close button of the browser..
Pls. help
0
Comment
Question by:kulsmadya
  • 2
  • 2
  • 2
  • +5
12 Comments
 
LVL 8

Expert Comment

by:edemcs
ID: 6196081
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
 
LVL 9

Expert Comment

by:nimaig
ID: 6196119
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
 

Author Comment

by:kulsmadya
ID: 6196131
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
 
LVL 10

Expert Comment

by:dij8
ID: 6196171
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
 
LVL 9

Expert Comment

by:nimaig
ID: 6196226
It is not possible ..........
0
 

Author Comment

by:kulsmadya
ID: 6196244
so what would be the work arround??
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 10

Expert Comment

by:dij8
ID: 6196276
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
 
LVL 8

Accepted Solution

by:
edemcs earned 200 total points
ID: 6196359
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
 
LVL 7

Expert Comment

by:daniel_c
ID: 6196917
0
 

Expert Comment

by:kamcheungon
ID: 6209020
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
 
LVL 1

Expert Comment

by:Moondancer
ID: 6833207
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
 
LVL 5

Expert Comment

by:Netminder
ID: 6891296
Force-accepted by
Netminder
CS Moderator
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now