[thelist] href=# versus href=JavaScript.....

s t e f stef at nota-bene.org
Thu Feb 22 05:21:29 CST 2001


[sender: N at ta$ || date: 20:45 21/02/2001 -0600]
>I use the '#' system myself and have a question since this issue got me
>thinking...
>
>I visited one of my more recent site and am curious:
>
>My current anchor code is:
>
><A HREF="#"
>onClick="window.open('http://www.dagl.net/images/botd/babe45.jpg','BOTD','scrollbars,WIDTH=399,HEIGHT=620');"
>onMouseOver="imageSwap('babe', 
>'http://www.dagl.net/images/babe_title_on.gif') ,
>self.status='Babe of the Day'; return true;" onMouseOut="imageSwap('babe',
>'http://www.dagl.net/images/babe_title.gif') , self.status=' '; return
>true;"><IMG NAME=babe SRC=http://www.dagl.net/images/babe_title.gif WIDTH=226
>HEIGHT=25 HSPACE=0 VSPACE=0 BORDER=0 ALT="."></A>
>
>however, whenever the image link is clicked on and the popup opens, the parent
>window also reloads the main page in which the image resides...does the
>"javascript:" system eliminate this? If so, then I should be using that method
>instead...
>
>If not, does anyone know how to correct the reload?

Of course yes, and since nobody answered, here are my two cents :

<a href="#" onclick="anyFunction(anyArgs); return false;">link</a>
The return false tells the browser not to follow the link.
Pointing to # is not a double load of work for the browser since return 
false forbids it following the link.
More over, pointing to "#" degrades better when Javascript is disabled. 
Nothing happens except a reload.

s t e f





More information about the thelist mailing list