Subj : Re: Equivalent of JS_InitClass for global object? To : John J Lee From : Brendan Eich Date : Mon Aug 25 2003 01:58 pm John J Lee wrote: >I'll take your word for that, but I don't understand why (I *do* still >have window objects in Python -- it's just that rather than bind one >directly as the global object, I just have a function bind_window that >fakes a JS global object by grabbing the individual attributes and methods >from a window object and binding them to my simple JS global object). > Windows are global objects in the DOM level 0, so a variable (var x = 42, e.g.) or function declaration (function f() {return 42;} at top-level) finds a property of the global object, which can be fetched via window.x or window.f, or if in another window accessible according to security policy and frame/framset or window.open call prerequisites, otherWindow.x or otherWindow.f. Plus, you can count on window object identity invariance: otherWindow.myWindow = window; ; assert(otherWindow.myWindow == window). Does your window object not being the global object magically satisfy these constraints? >What's the best way to find out about this kind of thing? ATM, I don't >know, for example, whether all these frames / windows have their own >scopes / global objects / JSContexts -- your answer seems to hint at >something like this. Am I stuck with either attempting to read the >Mozilla source, or guessing by looking at piles of real-world JS code? > Other browsers have managed to implement the DOM level 0, even though the w3c never stepped up and standardized it. Perhaps the question of specifying it enough for you to implement it without reading Mozilla sources should be turned over to the w3c. Or to the news://news.mozilla.org/netscape.public.mozilla.dom newsgroup, at least. /be .