Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
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
 
Old October 19th, 2007, 12:12 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default 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
 
Old October 19th, 2007, 03:09 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

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
 
Old October 21st, 2007, 06:45 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Wow that works an abosolute charm. Thankyou for your time, this solution is tops!!!

Wind is your friend
Matt
 
Old October 22nd, 2007, 01:10 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
 
Old October 22nd, 2007, 02:26 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

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
 
Old October 22nd, 2007, 05:16 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

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
 
Old October 23rd, 2007, 12:32 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
 
Old October 23rd, 2007, 01:43 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

I see, thankyou for the clarrification. I do believe useful for my situation

Thanking Vinod and Imar...

Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
parent child connect s2mo SQL Server 2005 1 February 20th, 2007 07:16 AM
parent child presentation db96s1 Beginning PHP 0 February 7th, 2006 06:19 PM
Parent - Child Combo babloo81 BOOK: Professional Jakarta Struts 0 April 27th, 2005 01:54 PM
Parent - Child Combo babloo81 JSP Basics 0 April 27th, 2005 01:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.