Javascripted stylesheet switchers - evil or not? - ΩJr. Software Articles and Products

This information lives on a web page hosted at the following web address: 'https://omegajunior.globat.com/code/'.

A user-hating web browser like Safari or Chrome fails to incorporate alternate stylesheet switchers. Exploring the problem and solutions.

A.E.Veltstra
Monday, November 23, 2009

All web browsers that are built with ease of use in mind, sport accessibility options. Microsoft Internet Explorer has fared well in this respect, for as long as I can remember. Then Opera and Firefox started offering more. Microsoft wised up and added a stylesheet selector to its interface starting at MSIE8.

But, if you happen to be using Safari or Chrome, you're S.O.L. Apparently, the vendors don't care about user accessibility. No. They must hate you.

Why? Because they don't offer a stylesheet switcher.

What's a stylesheet switcher?

If a web author is nice enough to think about the different machines on which their web page could be shown, the smart author offers the same well-formed web page in varying layouts. These layouts are called stylesheets.

By setting the media attribute, a web author can determine whether a stylesheet should be loaded by a printer, a desktop web browser, a small-screen web browser, a big-screen projector, or something else. Some authors offer different layouts for the same machine. Sometimes just to spice things up, and sometimes to make their web page easier to use under certain circumstances.

Those stylesheets are called 'alternate stylesheets'. User-friendly web browsers recognise these, and offer a switch in their menu, to let the user switch between one layout and the other. (The web authors know that this switch also comes in handy when testing their stylesheets for other media.)

A user-hating web browser fails to incorporate such a switch. Knowingly, they prevent the user from using something the web author has created to make their lives easier, resulting in the browser making the user's life harder.

Not good.

The web author then starts looking for ways to enable it anyway. I consider this evil: building into a web page, what the browser should've offered.

We see other examples of such necessary evil: font size changers, rss feed icons, bookmarking facilities... all created to overcome browser deficiencies. Necessary evil.

Apparently, for stylesheets, the user-hating browsers seem Safari and Chrome. The way for the web author to get those browsers to offer a stylesheet switch to their users anyway, is by building it into their web page.

This can be done using javascript. All it seems to take, is look for the [ rel=alternate stylesheet ] and turn it into [ rel=stylesheet ]. (Edited to correct that: it also takes setting [ disabled=false|true ].)

And the other way around, of course.

And allow for some stylesheets to remain active while others are switched around.

I wonder what such switchers do to interface of the user-friendly browsers, that provide such a switch themselves...

Need problem solving?

Talk to me. Let's meet for coffee or over lunch. Mail me at “omegajunior at protonmail dot com”.