 |
| Javascript General Javascript discussions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 19th, 2007, 12:12 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
Refresh parent onclose of child
I can and usually achieve this by placing a close window button. Is there a way to achiever this after the user clicks IE's red X?
Please note : I am coding in a strict IE 6.0 SP2 SOE using Classic ASP
TYIA
Wind is your friend
Matt
__________________
Wind is your friend
Matt
|
|

October 19th, 2007, 03:09 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi Matt!!
<script>
function closeSession()
{
//capturing ALT + F4
if (event.altKey==true && event.keyCode==0 )
{
//alert("closed1")
window.close();
if (window.opener && !window.opener.closed) {
window.opener.location.reload();
}
}
Xwidth=window.document.body.offsetWidth-window.event.clientX
YHeight=window.event.clientY
if(Xwidth<=30&&YHeight<0)
{
window.close();
if (window.opener && !window.opener.closed) {
window.opener.location.reload();
}
}
}
window.onbeforeunload=closeSession
//or we can use body(unload) method
</script>
Hope this will help you
Cheers :)
vinod
|
|

October 21st, 2007, 06:45 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
Wow that works an abosolute charm. Thankyou for your time, this solution is tops!!!
Wind is your friend
Matt
|
|

October 22nd, 2007, 01:10 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Doesn't onbeforeunload fire for *every* request, killing your session every time you browse to another page?
You could do this in a parent frame, as that's likely to be unloaded only when the entire application is closed.
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
|
|

October 22nd, 2007, 02:26 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hii Imar!!
You are right,It was my mistake ,i had given wrong function name for this example.
Actually I had written this code to track the session end time for one application and when question was found in forum i just put it.I know it's bad programming practice ,i will take care abt this.
Cheers :)
vinod
|
|

October 22nd, 2007, 05:16 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
What negative impact functionaly should I see?
It seems to be working without noticible issue. It is in place to update the dynamic details of the parent which was updated via a form using a child window.
TYIA
Wind is your friend
Matt
|
|

October 23rd, 2007, 12:32 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Matt,
It depends on what it does. If all you need to do is refresh the parent when the window closes, you're pretty safe.
However, people often use this method to call something like Session.Abandon() because they think it only fires when the browser is closed, not when the page unloads. If you do that, you'll find that your session gets killed on every page, resulting in a new session every time.
But again, on rereading your original post, I'd say you're safe.
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
|
|

October 23rd, 2007, 01:43 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
I see, thankyou for the clarrification. I do believe useful for my situation
Thanking Vinod and Imar...
Wind is your friend
Matt
|
|
 |