Archives

September 30, 2007

Progressive enhancement with jQuery

Filed under: Accessibility, Web development, javascript — bryan @ 3:34 pm

I’ve been having a lot of fun with jQuery recently. One of the things particularly easy to do with it is write nice and unobtrusive javascript (a good start when looking at progressive enhancement). This is largely down to the fact that it’s very easy to find particular elements within the DOM - with any level of specificity - and attach behaviour to them.

On the site I’ve been building at work, one particular example was to get jQuery to write in the “Print page” link, since that needs javascript.

// add print page link - since it can only work for JS, only add it for JS users
$('<li></li>') // create list item
    .addClass('print') //add relevant class to it
    .append('<a href="javascript:window.print();">Print this page</a>') //put in the link
    .insertBefore('li a.foo'); //add before the li item with link of class 'foo'

The above example is slightly more verbose than it need be, but it illustrates some of the different built-in functionalities of jQuery quite well.
Continue reading Progressive enhancement with jQuery

September 12, 2007

Web writing guidelines

Filed under: Accessibility, Web development — bryan @ 11:35 pm

Writing for the web is very different from writing for print. Key reasons for this are:

  • Users scan web pages rather than reading every word.
  • Users typically won’t give a web page their full attention. For example, they may also be listening to music and using instant messaging.
  • Web pages are interactive.

The six elementary rules

George Orwell’s rules (”Politics and the English Language”, 1946) are just as relevant today for the web.

  1. Never use a metaphor, simile or other figure of speech which you are used to seeing in print. [The point here is not "print vs. web" but "avoid ones which are used all the time".]
  2. Never use a long word where a short one will do.
  3. If it is possible to cut out a word, always cut it out.
  4. Never use the passive where you can use the active.
  5. Never use a foreign phrase, a scientific word or a jargon word if you can think of an everyday English equivalent.
  6. Break any of these rules sooner than say anything outright barbarous.

Continue reading Web writing guidelines