Closed Bug 68913 Opened 24 years ago Closed 24 years ago

window.opener method returns object for all pages

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows NT
defect
Not set
major

Tracking

()

VERIFIED INVALID

People

(Reporter: asreddy_74, Assigned: jst)

References

()

Details

Attachments

(1 file)

Check example below

<HTML>
<HEAD>
<TITLE>Test opener</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function test() {
alert(typeof( window.opener ));
}
alert("typeof( window.opener ) " + typeof( window.opener ));
</SCRIPT>
</HEAD>
<BODY>
<INPUT TYPE="button" VALUE="Get window opener again" onClick="test()">
</FORM>
</BODY>
</HTML>

Tested on Mozilla - Mozilla/5.0 (Windows; U; WinNT4.0; en-US; m18) 
Gecko/20010131

Expected behaviour as in IE i.e. notdefined when not existing

Regards
Srinivas
I see object returned by typeof(window.opener) on build 2001021505 WinNT.

I tend to think this is not a bug. Netscape 4.x also returns object for 
typeof(window.opener). However, it does this because typeof(null) returns 
object. Mozilla has the same behavior: it returns null for window.opener and 
object for typeof.

JavaScript: The Definitive Guide by David Flanagan (O'Reilly) on page 81 says 
"The typeof operator evaluates to 'object' for objects, arrays, and 
(surprisingly) null."

It would seem checking for window.opener == null would be better than checking 
for typeof(window.opener) == undefined and would work with Netscape 4.x as well.

Based on this and common behavior with Netscape 4.x, I'm resolving this as 
Invalid. Change it back if you think this is a real bug.
Status: UNCONFIRMED → RESOLVED
Closed: 24 years ago
Resolution: --- → INVALID
Updated URL to have a similar testcase that shows both window.opener and 
typeof(window.opener).
Checking for window.opener == undefined or typeof(window.opener) == undefined is
definitely not the right thing to do, window.opener is always defined (and it's
always an object), but it could very well be null (which, as tpowell stated
above). Verified.
Status: RESOLVED → VERIFIED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: