JavaScript in links Mar08 '06

I hate having to do this:

<a href="#" ... >

I also hate doing this:

<a href="javascript:void(0)" ... >

So... as a "best practice," what is the best way to disable a link’s normal activity, on click?

I’ve toyed with leaving out the href attribute out, altogether, but I don’t know if that would validate.

Categories: JavaScript

Add Feedback (view all)

Leave feedback

Feedback

Input format: The editor controls below will assist with Markdown syntax.

Status

Sub-status

Your info

Uhh, it ate my code. a href="version for people without javascript or search engines" onclick="doStuff(); return false;" obviously wr ... Read more.

matthom is published and produced by Matt Thommes - an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from Chicago. Never one to conform, Matt intends to promote the effect the web has on our lives, in an effort to intensify, instruct, and clarify all that is happening around us.

Contact Matt

Similar Entries

Stats

0 unique visits since Mar08 '06

Recent Referrers (click)

Syndicate

Advertisements