Pohodo

Proper Link Implementation

Standard Links

If you want to validate your markup and you have links that pass parameters, you need to create those links correctly or the page won't validate.

Entity references start with an ampersand (&) and end with a semicolon (;). If you want to use a literal ampersand in your document you must encode it as "&" (even inside URLs!). Be careful to end entity references with a semicolon or your entity reference may get interpreted in connection with the following text. Also keep in mind that named entity references are case-sensitive; &Aelig; and æ are different characters.

This page explains it well: http://www.htmlhelp.com/tools/validator/problems.html#amp

WRONG <a href="http://www.pohodo.com?somevar=somevalue&othervar=othervalue">Some Link</a>

CORRECT <a href="http://www.pohodo.com?somevar=somevalue&amp;othervar=othervalue">Some Link</a>

Note that running URLs through Redirectors would be handled different. This can be a problem if a URL with parameters is assigned to a JSP variable and used in multiple places - you can't just change ampersands with &amp; and then encode that to go through a redirector.



Sometimes it is necessary to run a link through a redirector for tracking, or pop up a window using JavaScript.

If done incorrectly, the link will not be visible to search engines, or will not be accessible if opened in a new window or tab by the user.

Following are a couple of links to demonstrate the proper way to code more complex links...

JavaScript Popup Links

<a href="http://www.pohodo.com" onclick="openWin(this); return false;">Sample Popup Link</a>

Sample Popup Link

How it works - when a user clicks on the link, it fires off the openWin JS function and then returns false to the browser which effectively kills the original link. The "this" keyword represents the value of the href attribute - no need to write out the link again.

Pro - If a user right-clicks on the link to open in a new window or tab, the link will work perfectly fine and not return a JavaScript error.
Pro - A search engine can now clearly see that the link goes to the actual destination, rather than JavaScript jibberish. So that page can now be spidered for content.
Con - A user can open in new window or tab, so content of popup could look poor depending on the size of the window.

Redirector Links

<a href="http://www.pohodo.com?somevar=somevalue" onclick="window.location='http://www.
autotrader.com/redirect/redirector_link.jsp?to_url=http%3A%2F%2Fwww%2Epohodo%2Ecom%3Fsomevar
%3Dsomevalue&amp;mis=MISCODE'; return false;">Sample Redirector Link</a>

Sample Redirector Link

How it works - when a user clicks on the link, the onclick JavaScript event handler allows us to change the location field in the browser to move to the proper page. Then it returns false for the anchor link, which prevents the browser from following the actual link.

Pro - Search engines can now clearly see that the link goes to the actual destination, rather than the redirector page.
Con - If a user right-clicks on the link and opens in a new window or tab, then the onclick event is not triggered and the original link is used (not going through the redirector and thus not tracked as a click). This could become more of a problem if tabbed browsing becomes more popular and widespread.

I used this on links to a partner site because they wanted to get the link credit from search engines. They were suffering in organic results because search engines didn't know we were linking to them. Everybody understood the con and dismissed it as a problem.