Solved

onclose in js

Posted on 2002-04-17
13
890 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 

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
 
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

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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

729 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