BLOG: JavaScript Links or onClick Links?

JavaScript links, or links with javascript in the href attribute, cause problems for visitors who either turn off or don't have JavaScript support in their browsers. Not to be callous, but, in almost all cases, this percentage of your audience is small.

As a compromise, you can always use self-referential links that respond to onClick events. These links are easier for non-JavaScript browsers to handle, but then you have the problem of the browser jumping back to the top of the page. This inconveniences a larger cross-section of your audience than it helps.

If you really want to court the HTML purists, don't use JavaScript on your site, period. However, if you want or need the extra functionality, JavaScript ...

Get Web Design Garage now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.