Skip to content

Avoid the void(0) in IE6

by Jonathon on April 7th, 2010

I recently learned the hard way that <a href="javascript:void(0)"> doesn’t work as expected in IE6. The solution is to use the familiar # but make sure your onclick event returns false:

<a href="#" onclick="aFunction();return false;">Link</a>

d’bug has a great writeup on why this works and the other doesn’t.

From → Notebook

One Comment
  1. You shouldn’t use inline javascript in your links like that period, though the onlick event isn’t as bad.

    Ideally you’ll want to add a hook to your link like:

    My Link

    Then use a separate javascript file to add the click event to the link using the class as a way to identify it.

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS