On Feb 21, 9:18 am, Remi Grumeau  <[email protected]> wrote:
> On 21 févr. 2011, at 00:00, RobG <[email protected]> wrote:
>
> > On Feb 20, 6:16 am, "Rémi Grumeau" <[email protected]> wrote:
> >> Related to this "problem", here is a iUI modification i'd like to  
> >> submit to the list for reviewing.
> >> If an anchor link has the prefix "iuist-" (which stand for iui scroll  
> >> to), iUI will not try to go navigate with ajax to a screen but will  
> >> use default browser behavior.
>
> > Why not just allow anchors to behave as anchors? If an href starts
> > with # and there is an A element in the page with that name (i.e. you
> > find an href to an anchor), let the browser scroll to it.
>
> Didn't thought about it, pretty good point! I should prototype that.
> But I think what would "cost less" browser memory usage would be to check if 
> new anchor value is an existing screen (then perform followAjax() as now) and 
> if not, just perform default browser behavior.
> Result would more or less be the same but wouldn't require parsing current 
> screen DOM to find all a elements and test each name values.

You don't have to parse anything, use getElementsByName, e.g.

var isAnchor = (function() {
  var re = /^#/;
  return function (s) {

    if (re.test(s) &&
        document.getElementsByName(s.replace(re,'')).length) {

      // s is an anchor
      alert(s + ' is an anchor');
      return true;
    }

    alert(s + ' is not an anchor');
    return false;
  };
})();

If you want to be certain, you can iterate over the collection
returned by getElementsByName to see if one has tagName A.


--
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.

Reply via email to