473,396 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

closing a child window when parent window is closed is not working in mozilla

From a parent window a new child window is open with window.open

[HTML]<script type="text/javascript" language="JavaScript" >

function abc()
{

if(window.event.clientY <0 && window.event.clientY <-80 )
{
if (win2 && !win2.closed) // win 2 is the child window
{
alert("Do you want to close all windows");
win2.close();
}

}
else if (win2 && !win2.closed)
{
win2.close();
}

}
</script>


<body bgcolor="#F7F7ef" onUnload="abc()">
[/HTML]

This works with IE , Opera .. this code doesnt work with Mozilla Netscape. What i require when closing the parent page by clciking the X button it should give an alert that ur closing the pages . when logout is pressed , it should give an alert it should just close the child window .Could anyone give me a solution for this
Nov 26 '07 #1
4 3158
acoder
16,027 Expert Mod 8TB
You can't check for browser close.

If you want to close child windows, close them onunload.
Nov 27 '07 #2
You can't check for browser close.

If you want to close child windows, close them onunload.
Thank You acoder

What i need is when we click on close button on the parent window it should give an alert and close child window whereas while logging out and session timeout it shouldnt give an alert and should close the child window

for that in the function a condition is being checked

Expand|Select|Wrap|Line Numbers
  1. function a
  2. {
  3. if(window.event.clientX<0 && window.event.clientY<-80)
  4. {   
  5.    if (win2 && !win2.closed) 
  6.       {
  7.            alert("closing all windows");
  8.             win2.close();
  9.      }
  10.  }
  11. else
  12. {
  13.     if (win2 && !win2.closed) 
  14.       {
  15.            win2.close();
  16.      }
  17. }
  18.  
  19. }
  20.  
window.event.clientX &Ynear close button is -ve no's
other than that for session and logout it will not give an alert
this function is called on onunload event of the parent window

Like this for mozilla it is window.screenX and window.screenY
i tried using that it gives only one value anywhere i click on the browser (-4,-4)

if anyone could tell why that is it would be very helpful...
Nov 28 '07 #3
You can't check for browser close.

If you want to close child windows, close them onunload.
Thank You acoder

What i need is when we click on close button on the parent window it should give an alert and close child window whereas while logging out and session timeout it shouldnt give an alert and should close the child window

for that in the function a condition is being checked

Expand|Select|Wrap|Line Numbers
  1. function a
  2. {
  3. if(window.event.clientX<0 && window.event.clientY<-80)
  4. {   
  5.    if (win2 && !win2.closed) 
  6.       {
  7.            alert("closing all windows");
  8.             win2.close();
  9.      }
  10.  }
  11. else
  12. {
  13.     if (win2 && !win2.closed) 
  14.       {
  15.            win2.close();
  16.      }
  17. }
  18.  
  19. }
  20.  
window.event.clientX &Ynear close button is -ve no's
other than that for session and logout it will not give an alert
this function is called on onunload event of the parent window

Like this for mozilla it is window.screenX and window.screenY
i tried using that it gives only one value anywhere i click on the browser (-4,-4)

if anyone could tell why that is it would be very helpful...
Nov 28 '07 #4
acoder
16,027 Expert Mod 8TB
Please use code tags when posting code. Thanks!
window.event.clientX &Ynear close button is -ve no's
other than that for session and logout it will not give an alert
this function is called on onunload event of the parent window

Like this for mozilla it is window.screenX and window.screenY
i tried using that it gives only one value anywhere i click on the browser (-4,-4)

if anyone could tell why that is it would be very helpful...
Mozilla/Firefox doesn't set the values to -80 (or some other number) when the window is closed. Just close the child windows onunload (which fires when you press refresh or back/forward too). Do you need the child windows away from the current page?
Nov 28 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Tom Szabo | last post by:
Is there an event when that triggers when the window is closing.... I am talking about when the user clicks on the cross on the right top corner of the window!!!
2
by: mannerfanner | last post by:
In order to reload the opener window from a child window I want to check the parent windows state. The following code works fine in IE and Mozilla: if(top.opener && !top.opener.closed) {...
5
by: Ron L | last post by:
I have an MDI application with a number of child windows. In each child window I am catching the Closing event and having the child window decide if it should set cancel to true. The intent here...
1
by: Chris Bruce | last post by:
In my application I need a way to distiguish between the following events: 1. When a user closes an MDI child window. 2. When the user closes the MDI parent window which subsequently closes the...
1
by: Tomas Vera | last post by:
Hello All, I'm working on a web app that will simulate a Windows app. One of the items that I've trouble reproducing is the parent/child interaction that might occur between a windo and popup...
6
by: Gary Miller | last post by:
Does anyone know how to detect a modeless form on closing by the form that invoked the modeless form? form.Show();
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
19
by: zacks | last post by:
I have a .NET 2.0 MDI application where the child form has a Tab Control. Each of the Tab in the Tab Control has a Validating event to handle what it should do when the user changes tabs. But...
7
by: sumanta123 | last post by:
Dear All, How will we do in JSP page on closing the parent window the child windows should close automatically. I will show my code Please i will show you my code. For HTML link function...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.