JavaScript links are evil

From Nick Jenkins
Revision as of 00:53, 9 November 2006 by 203.118.158.8 (Talk)

Jump to: navigation, search

Please don't use javascript for your links. Use standard HTML instead.

For example:

<a href="#" onClick="MM_openBrWindow('images/storyimages/040504_incident_report.html','','scrollbars=yes,width=840')">report</a>

There is simply no reason whatsoever for it. This works just as well like this:

<a href="images/storyimages/040504_incident_report.html" target="_blank">report</a>

And this:

<a href="javascript:KODAK('1.html')"  ...

Would become this:

<a href="1.html" target="_blank" ...

This has the following advantages:

  1. No loss of functionality - in fact, more functionality.
  2. Works even with Javascript turned off.
  3. Putting the cursor over the link shows in the status bar what it is - something that you don't get with JavaScript.
  4. Users hate popup windows.
  5. Works especially well in tabbed browsers (which is all of them, apart from IE6 - but IE7 will have tabbed browsing and has been).

Sites asked to consider above change

Site Date
SpamGourmet disposable email service. 15-Feb-2006
Pictures of Hong Kong buildings. 27-Feb-2006