On 17/3/03 20:02, "Stefano Mazzocchi" <[EMAIL PROTECTED]> wrote:
>> I share your "attach-a-method-to-an-object" concern, which certainly
>> comes from our heavy Java background.
>
> I'm sure it does, but after playing pretty hard with javascript for
> DHTML, I can tell you that the hardest thing for me to graps is the
> concept of why everybody uses
>
> alert("blah")
>
> why they use
>
> window.status = "blah"
>
> but never
>
> window.alert("blah");
>
> and
>
> status = "blah";
>
> In my mind, this means that not many understand that the 'window' object
> is transparently mapped to the global unnamespaced object.... but it
> creates a mess because you could have 'status' defined in your scripts
> as well.
>
> This is why I want a clean unnamespaced object.
>
> I would not mind log methods such as
>
> info("blah");
> error("blah");
> debug("lkj");
>
> but that should be it.
Well.. The "global" can also be referred to as "this"... So you can also
write:
alert("alert");
window.alert("window.alert");
this.alert("this.alert");
this.window.alert("this.window.alert");
....
That said, I believe that the best way to define global operations and
attributes is to define them in a so called "script" object, whose instance
is the one you're going to call from the sitemap...
So, "cocoon.sendPage()" becomes "this.cocoon.sendPage()"... JavaScript, as
Java, allows you to strip out the "this."...
Pier