Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

for (... in <object>) works weird in Netscape 4.7

2 views
Skip to first unread message

jsu...@anon.com

unread,
Dec 29, 2001, 1:15:59 PM12/29/01
to
Executing statement:

for (i in window)

doesn't return all properties in Netscape 4.7. Specifically, it
doesn't return statusbar and menubar, among others.

typeof(window.statusbar) returns "object"
window.statusbar.constructor returns:

"function Bar() { [native code] }"

Isn't the "for (... in <object>)" statement supposed to return all the
properties of the object? Is this a bug in Netscape 4.7? Is there any
workaround?

Douglas Crockford

unread,
Dec 29, 2001, 4:08:12 PM12/29/01
to

It is not a bug. Object properties can be marked DONTENUM, which causes them
to be ignored by for...in.

http://home.earthlink.net/~crockford/javascript/recommend.html


Janwillem Borleffs

unread,
Dec 29, 2001, 4:13:57 PM12/29/01
to

<jsu...@anon.com> schreef in bericht
news:ui1s2us5aui3krv89...@4ax.com...

> Executing statement:
>
> for (i in window)
>
> doesn't return all properties in Netscape 4.7. Specifically, it
> doesn't return statusbar and menubar, among others.
>

Actually, the status property IS returned. Try this:

<SCRIPT LANGUAGE="JavaScript">
// Set a status text
window.status="Some text";
var s = "";
// Loop through the object
for (i in window) {
s += i + "=" + window[i]+"<br>";
}
document.write(s);
</SCRIPT>

Search in the generated method listing for 'status' and you will find:

status=Some text

Regards,
Janwillem

jsu...@anon.com

unread,
Dec 29, 2001, 4:27:59 PM12/29/01
to
A slight misunderstanding. Yes, the function does return the "status"
property but not the "statusbar" property. The statusbar is the area
where the status is displayed, not the contents of the status.

Martin Honnen

unread,
Dec 29, 2001, 4:52:07 PM12/29/01
to
Properties of an object are not necessarily enumeratable. The ECMAScript
standard usually specifies for the core objects which properties are
enumeratable and which not but for application objects like the window
object every implementor is free to choose whether to enumerate objects
or not. Usually NN exposes a lot more properties than IE or Opera do

jsu...@anon.com wrote:


--

Martin Honnen
http://javascript.faqts.com/
http://home.t-online.de/home/martin.honnen/jsgoddies.html

jsu...@anon.com

unread,
Dec 29, 2001, 6:15:14 PM12/29/01
to
Thanks for the info.

jsu...@anon.com

unread,
Dec 29, 2001, 6:15:55 PM12/29/01
to
Thanks for the info
0 new messages