Prevent self linking

It's often the case that a web page links to itself. This can be frustrating for the user, especially if the page takes a long time to load.

Instead of self-linking, a page can suppress links to itself, and at the same time highlight the link text in some way, to clearly indicate the current page. The user is able to painlessly answer the common question "Where am I on this site?", at the same time as they are prevented from following a link that is usually useless. Such a style clearly has more compassion for the user's experience.

There are two ways to avoid self-linking in a set of navigation links :

For the dynamic style, there is no standard way to define how such links are suppressed. An implementation might rely on a naming convention, for example, to identify self-linking items that should be altered in some manner. In addition, the dynamic style could be implemented either on the server (Java), or on the client (Javascript).


This example uses WEB4J's HighlightCurrentPage custom tag to dynamically avoid self-linking. In this case, the implementation is on the server.

The following JSP snippet appears in a template, and displays a small navigation bar. At runtime, one link in the navigation bar is suppressed, and shows only plain text instead of the full link. In addition, it highlights the text (using a CSS class) to render it more obvious as the current page. This is all implemented with <w:highlightCurrentPage>. The tag uses one of two policies to identify links that are to be altered:

<div class="menu-bar">
 <w:highlightCurrentPage styleClass='highlight'>
  <c:url value="/main/home/" var="homeURL"/> 
  <A href='${homeURL}'>Home</a>
  <c:url value="/main/rsvp/" var="showRsvpURL"/> 
  <A href='${showRsvpURL}'>Rsvp</a>
  <c:url value="/main/visit/" var="visitEditURL"/> 
  <A HREF='${visitEditURL}'>Visits</A>
  <c:url value="/main/rating/" var="ratingEditURL"/> 
  <A HREF='${ratingEditURL}'>Ratings</A>
  <c:url value="/all/logoff/" var="logoffURL"/> 
  <A href='${logoffURL}'>Log Off</a>

See Also :
Web usability guidelines
A Web App Framework WEB4J