Solved

onclose in js

Posted on 2002-04-17
13
877 Views
Last Modified: 2008-03-10
Hello.

I need to delele a cookie when a window is closed. I know there is no onclose event and as far I understood the only possiblitly is to use the onUnload event in the body tag.

Is there any solution to my requeriment working for Netscape and IE?

Thanks in advance
0
Comment
Question by:perevicente
  • 8
  • 3
  • 2
13 Comments
 
LVL 2

Expert Comment

by:serg111
ID: 6947682
You can use session cookie that will be autodeleted after session close without your intervention or set expire time in 10 minutes
0
 

Author Comment

by:perevicente
ID: 6947711
I have two windows opened in the same brower session (one is open with ctrl+N or a link from the first window).

When I close the new one I want to delete the cookie that it sets, but If I close the window without any action the first window remains open and the cookie is still theres (untill all the windows session are closed). That is the reason because I want to delete the cookie when I close the 2nd window.

Does anyone know how to do it correcty for IE and Netscape?

Thanks
0
 
LVL 19

Expert Comment

by:webwoman
ID: 6947748
Why delete it? Why not just reset it in the other window? And I'm not clear why it's a problem...if you don't need it, you don't use it.
0
 

Author Comment

by:perevicente
ID: 6947767
I have a site with a session id depending on the value of a cookie. When I open a link form the first window to open a new site a new cookie is set. If I close this second window the cookie is still there, so if I open again a second window from the first one the cookie exists and I NEED there is no cookie when I open a second window from the first one.
0
 

Author Comment

by:perevicente
ID: 6947800
I have a site with a session id depending on the value of a cookie. When I open a link form the first window to open a new site a new cookie is set. If I close this second window the cookie is still there, so if I open again a second window from the first one the cookie exists and I NEED there is no cookie when I open a second window from the first one.
0
 
LVL 2

Expert Comment

by:serg111
ID: 6947977
You can provide button "Logout" - when user click it - cookies deleted and set timeout for session (or period of inactivity)
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 2

Expert Comment

by:serg111
ID: 6948008
Also if user opens 3 or more windows to your web site and later close one only - should cookies be deleted?
0
 

Author Comment

by:perevicente
ID: 6948027
1er answer: Button logout is not a solution. Most of the users never click it. They simply close the window.

2on : yes

Thanks for your hep but I need to get straight to the point. Is there any way of executing a javascript function just when a window is being close? (working for IE and NN)

Thanks.
0
 

Author Comment

by:perevicente
ID: 6948064
1er answer: Button logout is not a solution. Most of the users never click it. They simply close the window.

2on : yes

Thanks for your hep but I need to get straight to the point. Is there any way of executing a javascript function just when a window is being close? (working for IE and NN)

Thanks.
0
 

Author Comment

by:perevicente
ID: 6948110
1er answer: Button logout is not a solution. Most of the users never click it. They simply close the window.

2on : yes

Thanks for your hep but I need to get straight to the point. Is there any way of executing a javascript function just when a window is being close? (working for IE and NN)

Thanks.
0
 

Author Comment

by:perevicente
ID: 6948160
1er answer: Button logout is not a solution. Most of the users never click it. They simply close the window.

2on : yes

Thanks for your hep but I need to get straight to the point. Is there any way of executing a javascript function just when a window is being close? (working for IE and NN)

Thanks.
0
 

Author Comment

by:perevicente
ID: 6948224
1er answer: Button logout is not a solution. Most of the users never click it. They simply close the window.

2on : yes

Thanks for your hep but I need to get straight to the point. Is there any way of executing a javascript function just when a window is being close? (working for IE and NN)

Thanks.
0
 
LVL 19

Accepted Solution

by:
webwoman earned 80 total points
ID: 6948692
Short answer -- no. You don't know the window is being closed. You only know the page is being unloaded -- maybe. If they close the window without using any buttons you have, even the unload may not be triggered.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

708 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

18 Experts available now in Live!

Get 1:1 Help Now