You are here:

  1. Manual
  2. Development
  3. Links and navigation
  4. Client-side scripts

Links and navigation: Links and client-side scripts

Sometimes links on a page refer to a client-side script function, a script that is executed in the browser; for instance, to open a new window or to display a menu. These links are often inaccessible to search spiders and visitors without client-side script support. However, web developers can show some consideration and apply a few simple rules.

More on the use of scripts can be found in the chapter Client-side scripting.

Client-side scripts as a supplement to server-side functions

If scripts are not supported, a link with script functionality can also revert to functions that will be executed on the web server. If this concerns critical functionality (in other words, if the usability of the website depends on it), this is even a necessity.

When using client-side script in combination with a link: if necessary, use client-side script as an extension of server-side functions.

Guideline R-pd.8.7

On the other hand, client-side script could improve a server-side function that is already present. Take, for example, a link for changing the style sheet:

A link to a server-side script, extended by means of client-side functionality(HTML)

<a href="index.php?stylesheet=4"
 onclick="changeStylesheet(4); return false;">

If script support fails, following the link will result in a page that loads with an alternative style sheet. In this example, this is caused by a PHP function on the server. Upon following the link, the page is refreshed before the result becomes visible.

If client-side script support is available, the script will execute the function changeStylesheet which immediately converts the page to an alternative style sheet, without having to refresh the page from the server.

This type of script functionality often occurs in relation to forms. A function checks the validity of the form before sending it. If scripts are not supported, the form is sent and a server-side function does al the hard work. This method relieves the server. Moreover, visitors with script support a rapid response if they fill in forms incorrectly. The form remains accessible.


Web Guidelines version 1.3, November 2007.