473,324 Members | 2,254 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,324 software developers and data experts.

What is the difference between window.parent and window?


In Firefox if an HTML page is not hosted inside a frame or iframe, the
following return true:

(window === window.self);
(window === window.parent);
But in IE they return false (using == returns true for both). Can
someone explain why?

Saying "It's DOM 0 so anything goes" is a cop-out. :-)
A test:

function testSelf()
{
alert('window === window.self: ' + (window === window.self)
+ '\n'
+ 'window === window.parent: ' + (window === window.parent)
);
}

window.onload = testSelf;
And in a related incident... testThing() returns true in both browsers:

function Thing(){
this.mySelf = this;
}

function testThing()
{
var x = new Thing();
return x.mySelf === x;
}

alert(testThing());

--
Rob
Jan 9 '06 #1
3 2675
RobG wrote:

"In Firefox if an HTML page is not hosted inside a frame or iframe, the
following return true:

******(window === window.self);
***(window === window.parent);

But in IE they return false (using == returns true for both). Can
someone explain why?
Saying "It's DOM 0 so anything goes" is a cop-out. :-)

A test:
******function testSelf()
******{
**********alert('window === window.self: ' + (window
=== window.self)
******************+ '\n'
******************+ 'window ===
window.parent: ' + (window === window.parent)
;
******}
******window.onload = testSelf;"

For what it's worth, this is the result with WebTV:

window === window.self: true
window === window.parent: true

We are at the level of IE4, not completely though. As a matter of fact,
barely IE4.

With regards to the results you're getting at your end, and taking into
consideration my very basic understanding of the difference between ==
and ===, it's as if IE is saying it's sort of true but not exactly.
Which doesn't make sense to me.

Later, Art.

Jan 9 '06 #2
X l e c t r i c wrote:
[...]

For what it's worth, this is the result with WebTV:

window === window.self: true
window === window.parent: true

We are at the level of IE4, not completely though. As a matter of fact,
barely IE4.
That's sad!

With regards to the results you're getting at your end, and taking into
consideration my very basic understanding of the difference between ==
and ===, it's as if IE is saying it's sort of true but not exactly.
Which doesn't make sense to me.


Exactly. It says to me that they refer to the same object (==), but
somehow that object is not identically equivalent (===) to itself.

I thought maybe it was because the reference is different, but in then
testThing() should also give false.

--
Rob
Jan 9 '06 #3
RobG wrote:

"Exactly. It says to me that they refer to the same object (==), but
somehow that object is not identically equivalent (===) to itself.

I thought maybe it was because the reference is different, but in then
testThing() should also give false."

Even though parent and self are a reference to the window, I wondered if
Explorer might be seeing window.parent and window.self as object object.

But when I did a typeof check for window, window.parent, window.self,
parent, and self, they all were object on both Explorer and Firefox.

Yes, it was a waste of time checking the obvious, but now I no longer
wonder. About that.

Later, Art.

Jan 9 '06 #4

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

Similar topics

5
by: Lee | last post by:
I am using a modal window and an iFrame to try and pull a return value back. I am doing this across domains. I have the value returned from the modal window to the iFrame window but I can not...
1
by: Filiz Duman | last post by:
Is it possible to call a javascript function based in the parent window from the child window ? I do open a pop up window from the parent window with: newwindow = window.open (...) and assign...
4
by: Hal | last post by:
Can someone please tell me what is wrong with this script? <script language="JavaScript"> <!-- function HF_CloseAllChildren() { if (g_win1) != undefined { if ((g_win1) && !(g_win1.closed))...
2
by: Robert Nurse | last post by:
Hi All, I'm trying to alter the contents of a drop-down (select) list on the parent window from a child window in IE 6. After opening the child window, I set its opener to reference the parent...
4
by: Paul | last post by:
HI! I have a script that does not seem to work. can someone tell me what I am doing wrong here? <script language="JavaScript"> function firefoxautofix(){ parent.window.resizeBy(-1,-1)...
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...
4
by: Earl Teigrob | last post by:
I am thinking about using a popup window to edit settings that will affect parent asp.net page. The data that is changed in the popup window will be saved to the datastore that is loaded and...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
2
by: epaetz | last post by:
Is there a way to decouple the linkage between a parent and a child window? Does the parent window have any sort of a collection that holds all the children that it has spawned? I want to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.