Italo, I think your code would be better integrated into Rajeev's
example.
$$('a') is going to grab every anchor on the page, and then run a test
against it, whereas Rajeev's example is only going to grab the anchors
inside the div with the id of 'myDiv' - which makes a lot more sense,
performance and code wise.
On Feb 12, 9:01 am, Italo Maia <[email protected]> wrote:
> $$('a').each(
> function(item,index){
> if (item.get('href').lastIndexOf(window.location.toString()))
> item.set('href', '#'); } );
>
> Try the code above!
>
> On 11 fev, 05:23, Rajeev J Sebastian <[email protected]>
> wrote:
>
> > On Wed, Feb 11, 2009 at 12:18 PM, Daiv Mowbray <[email protected]>
> > wrote:
>
> > > Hello nwhite,
>
> > > Thanx for the reply and suggestions.
>
> > > I have applied some of them and now I have this:
> > > function clear_link(){
> > > var unlinked = 0;
> > > mysplit = window.location.href.split('#')[0];
> > > a = $('#mydiv').getElements('a');
> > > for(var i=0;i<a.length;i++)
> > > if(a[i].href == mysplit){
> > > a[i].destroy(); // instead of
> > > removeNode(a[i]);
> > > var unlinked = 1;
> > > }
> > > if (unlinked == 0){
> > > var newHit = a[0];
>
> > > newHit.parentNode.setProperty('id','active_nav');
> > > }
> > > }
>
> > > But I am receiving the following error, any thoughts?
> > > $("#mydiv") is null
> > > [Break on this error] a = $('#mydiv').getElements('a');
>
> > In mootools, we do
> > $('mydiv') or $$('#mydiv') ... in the first case, you will get a
> > single Element and in the second, an array containing a single element
>
> > So the line is better written as:
>
> > $('mydiv').getElements('a');
>
> > Regards
> > Rajeev J Sebastian