Linking for accessibility & SEO
| June 21, 2004, 12:50 pmLinks are the glue that holds the web together, everybody loves them. Or do they? There are however those that would build links in a way that they can't be followed. Madness, yes! but true none the less.
Some links are used to open up new windows with javaScript, which is fine if you have javaScript enabled, however if you are a screen reader or a search engine spider then that javaScript link could be nothing less than a brick wall.
That bad code looks something like this:
<a href="javascript: viewpage();">
So we've seen the evil twin, what about the good brother?:
<a href="page.html" onclick="viewpage(); return false;">The target page</a>
When we write the link like this, if the browser has javaScript enabled the window pops up, with return false preventing the original text link from working.
If the browser does not have javaScript, we open up the new page in the existing window. And everyone's happy.
Further Reading:
http://www.webaim.org/techniques/javascript/
