opener.opener ?

Y

Yaron C.

Hi,

I have window A, which open popup A which Open popup C.

In the two popups I use a common JavaScript file and in order to
distinguish between them I use the following code:


if (typeof(opener.opener)=="object") {
alert("1");
}
else if (typeof(opener)=="object") {
alert("2");
}

The problem is that I get "1" for both popups.
I.e. "opener.opener" exists also for popup A.


Any ideas ?

Thanks,
Yaron
 
T

Thomas 'PointedEars' Lahn

Yaron said:
I have window A, which open popup A which Open popup C.

In the two popups I use a common JavaScript file and in order to
distinguish between them I use the following code:


if (typeof(opener.opener)=="object") {
alert("1");
}
else if (typeof(opener)=="object") {
alert("2");
}

The problem is that I get "1" for both popups.
I.e. "opener.opener" exists also for popup A.

AFAIS, the value of the `opener' property for a window not opened by another
window with client-side scripting is `null' which explains why you still get
`object' for its type (see the discussion a week or so ago).[1]
So

if (typeof opener != "undefined" && opener)
{
...
}

should suffice since `null' evaluates to `false' in a boolean expression.
More simple, but assuming that `opener' is a property of window, is

if (window.opener)
{
...
}


HTH

PointedEars
___________
[1] Suprisingly, alert(opener) then shows an "empty" message box, while
alert('"' + opener + '"') shows `"null"' in Mozilla/5.0 (Windows; U;
Windows NT 5.0; en-US; rv:1.6a) Gecko/20031025.
 
L

Lasse Reichstein Nielsen

Thomas 'PointedEars' Lahn said:
[1] Suprisingly, alert(opener) then shows an "empty" message box, while
alert('"' + opener + '"') shows `"null"' in Mozilla/5.0 (Windows; U;
Windows NT 5.0; en-US; rv:1.6a) Gecko/20031025.

Yes, it seems that in Mozilla
alert(null)
creates an empty alert (just as the empty string), while
alert(String(null))
ofcourse alerts the string "null".

In IE and Opera, alert(null) alerts the string "null", while alert()
gives the empty alert. Mozilla doesn't allow alert().

/L
 
T

Thomas 'PointedEars' Lahn

Lasse said:
Thomas 'PointedEars' Lahn said:
[1] Suprisingly, alert(opener) then shows an "empty" message box, while
alert('"' + opener + '"') shows `"null"' in Mozilla/5.0 (Windows; U;
Windows NT 5.0; en-US; rv:1.6a) Gecko/20031025.

Yes, it seems that in Mozilla
alert(null)
creates an empty alert (just as the empty string), while
alert(String(null))
ofcourse alerts the string "null".

In IE and Opera, alert(null) alerts the string "null", while alert()
gives the empty alert. Mozilla doesn't allow alert().

It is not an alert(...) issue since assigning `null' to the `value'
property of an HTMLTextArea object and then retrieving it without
alert(...) (namely assigning its value to it) also shows the empty
string, while assigning `String(null)' shows `null'.


PointedEars
 
Y

Yaron C.

Thanks !

Thomas 'PointedEars' Lahn said:
Lasse said:
Thomas 'PointedEars' Lahn said:
[1] Suprisingly, alert(opener) then shows an "empty" message box, while
alert('"' + opener + '"') shows `"null"' in Mozilla/5.0 (Windows; U;
Windows NT 5.0; en-US; rv:1.6a) Gecko/20031025.

Yes, it seems that in Mozilla
alert(null)
creates an empty alert (just as the empty string), while
alert(String(null))
ofcourse alerts the string "null".

In IE and Opera, alert(null) alerts the string "null", while alert()
gives the empty alert. Mozilla doesn't allow alert().

It is not an alert(...) issue since assigning `null' to the `value'
property of an HTMLTextArea object and then retrieving it without
alert(...) (namely assigning its value to it) also shows the empty
string, while assigning `String(null)' shows `null'.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top