473,386 Members | 1,668 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Window Close

Hi Friends,
I have a problem for logout operation. whenever i close the browser of my application, I should indicate that the user has logged out without clicking the logout button.. I hav written a function on window close. The problem is that function is called for each time when i make a navigation to another window in my application.

Please help me how to solve this problem.
Mar 6 '07 #1
11 3416
dmjpro
2,476 2GB
r u using window.onbeforeunload = function_ref ?????????

if possible plz send ur code so that i can understand what u r using .....
Mar 6 '07 #2
acoder
16,027 Expert Mod 8TB
Hi Friends,
I have a problem for logout operation. whenever i close the browser of my application, I should indicate that the user has logged out without clicking the logout button.. I hav written a function on window close. The problem is that function is called for each time when i make a navigation to another window in my application.

Please help me how to solve this problem.
You don't need to inform the user that they have been logged out. If they close the window, they've logged themselves out (as long as you've coded that), or maybe there's a timeout after which they'll be logged out.
Mar 6 '07 #3
Hi Friends,
I have a problem for logout operation. whenever i close the browser of my application, I should indicate that the user has logged out without clicking the logout button.. I hav written a function on window close. The problem is that function is called for each time when i make a navigation to another window in my application.

Please help me how to solve this problem.
<html>
<head>
<script type="text/javascript">
var myclose = false;
function ConfirmClose()
{
if (event.clientY < 0)
{
myclose = true;
}
}
function HandleOnClose()
{
if (myclose==true)
{
window.open('http://www.google.com');
}
}
</script>
</HEAD>
<body topmargin='0' bottommargin='0' leftmargin='20' rightmargin='20' onbeforeunload="ConfirmClose()" onunload="HandleOnClose()">
</body>
</html>
Mar 7 '07 #4
Hi friends,
Thanx for ur timely help. It works well.
I found another solution to check whether the close button is clicked or not regardless of whether the browser is maximised or minimised.
it goes like this.......

//To check whether the user has clicked on the close button on top of window
function initUnload()
{
var top=self.screenTop;
//alert ("top"+top);
if (top>9000)
{

alert("Window is closed!!!!!!");
}
else if (top<0)
{
// check whether the user has minimised the window and closed it using right click options.

alert("Window is closed!!!!!!");

}
}


window.onunload = initUnload;
Mar 8 '07 #5
OnUnload works only in IE
wh about other browser - NN, Mozilla, Opera
Mar 8 '07 #6
acoder
16,027 Expert Mod 8TB
OnUnload works only in IE
wh about other browser - NN, Mozilla, Opera
onunload works in IE, FF, Netscape, Safari. Only Opera doesn't support it properly. See link and the famous event compatibility tables.
Mar 8 '07 #7
gauravgmbhr
107 100+
Hi Friends,
I have a problem for logout operation. whenever i close the browser of my application, I should indicate that the user has logged out without clicking the logout button.. I hav written a function on window close. The problem is that function is called for each time when i make a navigation to another window in my application.

Please help me how to solve this problem.

Send Ur code
wat u did
in order to get solution from the comminity members
Mar 8 '07 #8
hini
23
I faced the problem before but could not resolve it,
I searched for a javascript function to send a request to server page when the window is closed, and I tried onUnload.
the problem with onUnload is that it is executed even if I try to refresh the page.
Mar 9 '07 #9
acoder
16,027 Expert Mod 8TB
I faced the problem before but could not resolve it,
I searched for a javascript function to send a request to server page when the window is closed, and I tried onUnload.
the problem with onUnload is that it is executed even if I try to refresh the page.
You can use self.screenTop as suggested earlier, but I don't think it's supported by all browsers.
Mar 9 '07 #10
sorry me but it is not the good way

you have much bugs in this way!!!

You can write an script(ASP/ASP.Net/...) that chek your user that is in your web application or not!

that is not good!!!!
Mar 9 '07 #11
acoder
16,027 Expert Mod 8TB
sorry me but it is not the good way

you have much bugs in this way!!!

You can write an script(ASP/ASP.Net/...) that chek your user that is in your web application or not!

that is not good!!!!
True. Logouts should be dealt with on the server side. If the user closes the browser, let them. Log them out automatically using sessions if there's a period of inactivity, say 30 minutes. Then you don't have to worry about detecting if the user has closed the browser.
Mar 9 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Nigel Mercier ® | last post by:
I'm just starting to learn JavaScript, so far I like it! I want to add some JS to my Ebay listings, to manually open a pop-up window. It works OK, but the JS gets rejected by Ebay. If I can't...
3
by: Steve | last post by:
Hi, I have a nice little script that works well displaying images on my website. It's a script where if you clik a thumbnail image a pop up window opens that contains a larger version of the same...
9
by: Graham | last post by:
What I currently have is a page that opens another browser at 800x600, once that is loaded I would like to close the orginal page down while keeping the page that it has just opened open (To make...
4
by: GrantS | last post by:
I am having a problem closing a popup window opened modally. When I try to close the window (when the user hits save button and the data has been processed), the Popup window opens as a full screen...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
2
by: Tom | last post by:
How is the best way to avoid validation when closing a window? For instance, I have a Windows Forms window which has a validation event for a text box. However, if one enters invalid data in then...
5
by: lindanr | last post by:
In ASP.NET 2005 I have an onblur="window.close()" javascript event in the <body> tag. When I click on the window's scrollbar, the window closes. The same code works fine in ASP.NET 2003. Any...
9
by: Stan B | last post by:
I create a popup window by calling window.showModalDialog Popup window has Ok button with this code attached: === string Script = "<script language=JavaScript>" + "{" + "window.close();" +...
7
by: Toccoa | last post by:
After considerable googling - I mean searching with Google(r) - I could not find javascript on a button or <a href=... to close a window in the latest versions of IE and FireFox. There seemed...
2
by: kurt sune | last post by:
Hello, I have a weird problem, I hope someone can explain this for me. I have a webpage using masterpage. In it I create a popup window using this code: Dim js As String = "<script...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.