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.