On Feb 21, 11:53 pm, "Rémi Grumeau" <[email protected]> wrote:
> >>> Well, this would work but would select all <a> of the Dom,
>
> > getElementsByName() will only select every a in the DOM if every A
> > element has the same name, which would play havoc with anchors anyway.
>
> The thing is i don't want to select all a in the DOM
Good, because getElementsByName() almost certainly will not do that.
> because when i am
> currently viewing #test, i don't care about all a in #about or others.
> If the DOM is huge, your code will parse the whole DOM for all a
> elements.
You are thinking of getElementsBy*Tag*Name(), I'm saying use
getElementsByName() to get just the (one) element that has that name.
> That could cost latency, and anyway, is not needed. When i press on an
> anchor link, i usually only care about what i have rendered on the
> screen, not all hidden divs contents.
You do care if the href is to an anchor, which is what this is all
about.
> $(anchorvalue) just ask for one DOM element if exists or not.
By "anchorvalue" I presume you mean the href value with the leading #
(if there is one) removed. It is more common to use a@name for
anchors, iUI's $ function expects an id. There is one browser that
can't tell id from name, but iUI doesn't work in that browser anyway.
[...]
> >> On the other hand, only
> >> if($(anchorvalue))
> >> would do the job.
>
> > I don't know what that would do.
>
> last lines of iui.js:
> function $(id) { return document.getElementById(id); }
I was expecting you to be using the name attribute, not id, hence my
suggestion to use getElementsByName(). If you are using id, then you
should specify that anchors must use id, not name.
--
Rob
--
You received this message because you are subscribed to the Google Groups
"iPhoneWebDev" 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/iphonewebdev?hl=en.