On Sat, Nov 21, 2009 at 1:26 PM, Patrick Wiseman <[email protected]> wrote:
> Hello GM'ers:
>
> I'm having a funny problem with this.getAttribute.  Here's a couple of
> code snippets:
>
> function doWhatever() {
>  def=this.getAttribute('id');
> }
>
> This, as expected, assigns the value of 'id' to def.
>
> function doWhatever(abc) {
>  abc ? def=abc : def=this.getAttribute('id');
> }
>
> If abc is present, this assigns abc to def; but if abc is absent, it
> assigns [objectXPCNativeWrapper[objectMouseEvent]] to def (the
> this.getAttribute comes from a mouse click on the element with the
> 'id' attribute).  Any other combination does the same thing -
> def=this.getAttribute('id'), which works by itself, breaks the moment
> I try to assign it only if abc is absent.  I have the feeling I'm
> missing something obvious, but I'm trying to write ONE function which
> will behave the same way if passed a value or if getting a value from
> a clicked element.

try { def=this.getAttribute('id'); } catch(e) { def=abc; } does what I
want, but it doesn't seem right!

pw

--

You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=.


Reply via email to