method- vs. attribute-based access (was Re: does document.getEle...)

Jon,

Thanks the for clarification!  I was wondering why things like
http://www.taedium.com/svg/wave2.svg weren't working under Netscape;
I was trying to get event attributes directly ("event.clientX"
rather than "event.getClientX()".)

Was this mentioned in the release notes for the plugin?  I don't
remember seeing it.

I think
	if ( evt.getTarget() ) { target = evt.getTarget(); }
	else { target = evt.target; }

might fail with an 'unknown method' error if getTarget() is not
defined for the object (although a cursory glance through the javascript
reference doesn't tell me what the behavior is supposed to be.)  I
think turning it around
	if ( evt.target != null ) { target = evt.target; }
	else { target = evt.getTarget(); }

would work better since an unknown attribute returns null (undefined),
but unfortunately doesn't leave the regular DOM attribute-based access
as the default.  So, I just don't know what to do. :)

Thanks again,
Eric


>Date: Mon, 02 Oct 2000 11:24:19 -0700
>From: "Jon Ferraiolo" <jferraio@Adobe.COM>
>Subject: Re: does document.getElementId("MyElementId") work?

[cut]

>The reason the Adobe SVG Viewer doesn't support the "target" DOM attribute
>has to do with difficulties in dealing with Netscape's LiveConnect
>facility, which is the means for plugins to gain access to DOM facilities.
>LiveConnect puts Java between the plugin and JavaScript, which brings about
>severe implementation complications for all DOM attributes. Because of the
>complications, the Adobe SVG Viewer does not support any DOM attributes for
>NN4.x as attributes. Instead, it provides getter and setter functions, as
>in evt.getTarget(). The getters and setters are available in the Adobe SVG
>Viewer for both NN4.x and IE5.x. DOM-compliant direct access to the DOM
>attributes (e.g., evt.target) is only available for IE5.x.
>
>This limitation is most problematic for events. For most everything else in
>SVG, you can access DOM  values via method calls, such as getAttribute(...)
>and setAttribute(...). But there is no W3C-compliant method call for
>getting to DOM attributes on an event structure.
>
>One strategy is to access the 'target' as follows:
>
>var target;
>// getTarget() method necessary to overcome limitations with NN4.x
>if (evt.getTarget()) target = evt.getTarget();
>else target = evt.target;
>
>The above code sees if there is a getter method for the target attribute,
>and if so, then use it, else fall back to accessing the DOM attribute
>directly. I haven't done thorough testing of the above code, but I think it
>allows scripts to be written which will work with the Adobe SVG Viewer on
>all supported platforms and also with other implementations which do not
>implement the getter and setter functions.
>
>Jon

[ cut ]

Received on Monday, 2 October 2000 16:35:48 UTC