473,396 Members | 1,755 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.

Check the parent windows state from child.

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)
{
top.opener.location.reload();
}

BUT ... The state check works because IE recognises top.opener.closed
and Mozilla recognises top.opener. BUT IE does not recognise
top.opener and Mozilla does not recognise top.opener.closed.

I have seen this solution used on several sites. It can't be good
practise to fudge two statements together in one statement to make
them work for two different browsers.

Does anyone know of single method for checking window state which
works in IE and Mozilla?
Jul 23 '05 #1
2 5550
Have u tried to check "parent.document.readyState" ?

This should work both with ie and ns (in fact with all recent browsers)

"mannerfanner" <jo**********@gmail.com> a écrit dans le message de
news:2f**************************@posting.google.c om...
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)
{
top.opener.location.reload();
}

BUT ... The state check works because IE recognises top.opener.closed
and Mozilla recognises top.opener. BUT IE does not recognise
top.opener and Mozilla does not recognise top.opener.closed.

I have seen this solution used on several sites. It can't be good
practise to fudge two statements together in one statement to make
them work for two different browsers.

Does anyone know of single method for checking window state which
works in IE and Mozilla?

Jul 23 '05 #2
mannerfanner wrote:
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)
{
top.opener.location.reload();
}

BUT ... The state check works because IE recognises top.opener.closed
and Mozilla recognises top.opener. BUT IE does not recognise
top.opener and Mozilla does not recognise top.opener.closed.
How could IE 'recognize' top.opener.closed, but not top.opener? The
first is merely a property reference of the second's object.

What makes you say 'Mozilla does not recognise top.opener.closed'?
I have seen this solution used on several sites. It can't be good
practise to fudge two statements together in one statement to make
them work for two different browsers.

Does anyone know of single method for checking window state which
works in IE and Mozilla?


No fudge at all. By 'state' you presumably meant closed or not; all
window objects expose a .closed property (Boolean) indicating whether
the window has been closed, necessary as these objects persist even
after the window is off the desktop. Attempting to script a closed
window will throw an exception so, always check. Those aren't two
different approaches to checking 'state', they're a typical
illustration of evaluating object/property references one step at a
time to insure you never get beyond *one* undefined identifier.

if (top.opener ----> does 'opener' reference a window object?
&& !top.opener.closed) ----> OK, is it closed, or can I fiddle with it?

Compound Boolean expressions like this 'short-circuit' if any of the
evaluations, moving from left to right, have a result that makes the
overall outcome a forgone conclusion. For a compound &&,this means if
any operand evaluates to false (no point in continuing), and for || if
any operand is true (the entire expression is). You can use this
behavior to 'step gingerly out on a limb', so to speak, without hurting
yourself.

If I understood you correctly.

http://www.webreference.com/js/column6/object.html

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Omar Llanos | last post by:
I have Form1 and Form2 (which is inherited from Form1), and I created a button in Form2 that will fill up a textbox in Form1. What code would do that? I tried the simplest way: //from child...
8
by: Waleed Seada | last post by:
Hi all What need to be done to get the MDI parent call his MDI children Events, methods Thanks in advance /WS
2
by: Raj | last post by:
Hi All, I have a problem with trying to refresh the parent window from child window in order to update data in the parent window. The sequence of events are 1) I click a button in the parent...
1
by: Michael | last post by:
Hi Everyone, I seem to be having a problem accessing a menuitem on the MDIParent from a child form. From a login (frmSecurity -child form) screen, I need to hide a menuitem based on the users...
1
by: Eric | last post by:
I want to call a method on the MDI parent from the child. Basically the method will set some text (message) on a status strip and show the appropriate icon (for the type of message). I'd also...
1
by: bhargavi ramineni | last post by:
I have used the following javascript code to get a child window for parent window. childWin...
7
by: markrandolph | last post by:
I have parent.htm and child.htm ================================================================= In parent.htm we have: var parentarray = new Array(5) window.open("child.htm",.....) ...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.