Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

onclose in js

Posted on 2002-04-17
13
Medium Priority
?
897 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
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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

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'…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

715 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