By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,963 Members | 1,749 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,963 IT Pros & Developers. It's quick & easy.

opener.opener ?

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.