473,805 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.clo sed)
{
top.opener.loca tion.reload();
}

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

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 5584
Have u tried to check "parent.documen t.readyState" ?

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

"mannerfann er" <jo**********@g mail.com> a écrit dans le message de
news:2f******** *************** ***@posting.goo gle.com...
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.clo sed)
{
top.opener.loca tion.reload();
}

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

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.clo sed)
{
top.opener.loca tion.reload();
}

BUT ... The state check works because IE recognises top.opener.clos ed
and Mozilla recognises top.opener. BUT IE does not recognise
top.opener and Mozilla does not recognise top.opener.clos ed.
How could IE 'recognize' top.opener.clos ed, 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.clos ed'?
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.clo sed) ----> 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
3952
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 form in button2 clicked event: textbox1.Text = "Hello";
8
3764
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
23516
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 window to open a child window thru javascript window.open 2) I have some functionality in the child window that changes the data
1
2401
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 role. The problem is that I can't seem to get access to the menuitem. I can't get it with code like: MDIParent.mnuAdministrator.Visible = true MDIParent is the name of the form I gave. This is also the Startup form (in the project settings) if this...
1
5694
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 like to put a progress bar on the MDI parent and activate/manipulate it by the child What's the best way to do this? TIA
1
2632
by: bhargavi ramineni | last post by:
I have used the following javascript code to get a child window for parent window. childWin =window.open(url,"window","top=250,left=250,height=100,width=480,status=no,toolbar=no,menubar=no,location=no"); As the child window is not a modal dialog, user can minimize the window and do other actions in parent window. Please help me to avoid that. Even if the child window is minimized, when user tries to do some action in parent window, ...
7
5337
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",.....) ================================================================= In child.htm I want to add new elements to parentarray, like opener.parentarray = .......
7
4122
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 closeWin() {
0
9716
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10607
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10104
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9182
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7645
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3843
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.