467,212 Members | 1,203 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,212 developers. It's quick & easy.

opener.opener ?

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
Jul 20 '05 #1
  • viewed: 6617
Share:
4 Replies
Yaron C. wrote:
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.
Jul 20 '05 #2
Thomas 'PointedEars' Lahn <Po*********@web.de> writes:
[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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3
Lasse Reichstein Nielsen wrote:
Thomas 'PointedEars' Lahn <Po*********@web.de> writes:
[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
Jul 20 '05 #4
Thanks !

Thomas 'PointedEars' Lahn <Po*********@web.de> wrote in message news:<3F**************@PointedEars.de>...
Lasse Reichstein Nielsen wrote:
Thomas 'PointedEars' Lahn <Po*********@web.de> writes:
[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

Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Diana Coppenbarger | last post: by
1 post views Thread by Ray Slakinski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.