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

Tab Alleman talleman at autobex.com
Thu Feb 22 13:48:44 CST 2001


I know there's no shortage of pennies here, but I too have had cases where
href="javascript: ..." didn't work, but href="#" onclick="..." did work.  I
haven't discerned the pattern, so my solution is to try href="javascript"
first, and if it doesn't work, switch to href="#".  (Then if THAT doesn't
work, I debug my script.. :)

So my point to you is that it's not *always* sloppy coding.. sometimes it's
the only thing that seems to work.

And to Scott, using href="#" does screw up your history, unless you put more
javascript in there to fix it, and if a programmer's lazy enough to do
href="#", guess what?  :)

there's 2 more cents.. keep the receipt.

Tab

-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org]On Behalf Of Anthony Baratta
Sent: Wednesday, February 21, 2001 11:51 PM
To: thelist at lists.evolt.org
Subject: RE: [thelist] href=# versus href=JavaScript.....


At 06:44 PM 2/21/2001 -0600, you wrote:
>I thought href=# was the more proper of the two (considering '#' is used
for
>an inline anchor); and --not that this validates the statement-- I've
>watched browsers puke on a href=javascript: call, and that's outside the
>cases where javascript is just turned off ...
>
>(curiously) why does it irk you so?

Because of the way I think the browser works. Its trying to interpret the
href and go "somewhere", yet you're trying to using Javascript to do
something else, either related to another file or something with the
current page. This IMHO leads to confusion. Too many times have I seen
pages screwed up because of this.

What I'm not saying is that anchors are bad. I just think that if the HREF
is not designed to go to another page or anchor on the same page - you
shouldn't be using href=# as a place holder for "go no where". I have come
to the conclusion that its just sloppy coding.

Am I off base?

---
Anthony Baratta
President
Keyboard Jockeys


---------------------------------------
For unsubscribe and other options, including
the Tip Harvester and archive of TheList go to:
http://lists.evolt.org Workers of the Web, evolt !





More information about the thelist mailing list