[Project_owners] Finding Href

joe ertaba belaviyo at gmail.com
Mon Aug 27 13:58:07 PDT 2007


Thanks Karsten, my problem is solved.

On 8/28/07, Karsten Düsterloh <mnenhy at tprac.de> wrote:
>
> joe ertaba aber hob zu reden an und schrieb:
> > var target = e.target;
> > while(target.href == undefined)
> > target = target.parentNode;
> >
> > var href = target.href;
> >
> > it works good but it get error at line (while(target.href == undefined))
> > when target is not a link: Error: target has no properties
>
> You need to check that haven't passed the root node yet (whose
> parentNode will be null) and you should use the "in" operator to check
> for the href member instead of comparing against undefined:
>
> var target = e.target;
> while (target && !("href" in target))
>   target = target.parentNode;
> var href = target ? target.href : "";
>
>
> Karsten
> --
> Feel free to correct my English. :)
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mozdev.org/pipermail/project_owners/attachments/20070828/5d111078/attachment.html 


More information about the Project_owners mailing list