Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

onclose in js

Posted on 2002-04-17
13
Medium Priority
?
901 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

926 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