Ensure links work when Javascript doesn't
This weeks tip is: if you use Javascript to 'jazz up' the navigation on your website, make sure the links still work when javascript is turned off (or is not supported). For example, here is a technique I have seen used quite often on web pages; Javascript being used to open a new window when a user clicks a link:
<a href="javascript: popwin("/contact_us/default.htm")">Contact Us</a>
Note that in the above example the URL of the page being linked to will only appear as a result of running the script, so turning Javascript off means there will be no link to this particular page.
You can be sure that whatever you are trying to achieve with your javascript, there will be a more accessible way to do it, and that is true in this case. The following example is from Evolt.org, and shows how the same effect can be achieved without breaking the link:
<a
href="/contact_us/default.htm"
target="newWindow"
onclick="window.open(this.href, this.target); return false"
>Contact Us</a>
(Please note, the W3C guidelines say that you should always warn users before opening a new window.)