CSS selectors in web pages
n-roeser at gmx.net
Sun Sep 19 10:33:13 PDT 2004
-----BEGIN PGP SIGNED MESSAGE-----
Jeroen Coumans wrote:
> That's OK, we all have to party once in a while :-)
Thanks, the party was fine. :-)
Jeroen, I hit a problem here: each clickable link in the styleswitcher
currently has 3 pieces of information connected with it:
a) the name of the style to activate (same as the title attribute of the
link element to the stylesheet),
b) the value for the title attribute of the li element in the
styleswitcher (this text will usually be presented to the user as a
c) the text that is displayed and on which the user clicks to select
that particular style.
a) can be extracted from the DOM, no problem here.
b) and c) don't exist in the DOM (link element), so we're running into a
I *could* write something that uses c) as the title of the link element.
The advantage would be that the web page and the *browser* menu for
stylesheet selection (which is present in many browsers, e.g. Firefox,
Konqueror) use the same text. The downside is that it would break
existing cookies! And we couldn't change those texts anymore, once they
have been introduced, without breaking our users' cookies.
I don't have a solution in order to get b) into the DOM. Ideas?
It would be possible to create some kind of fallback, though: an array
of stylesheet names and the other info the script needs (like that
patch I sent earlier) which is used to extract the necessary info. If
it does not exist, we fall back to the default value (the value of the
title attribute of the link element) and no title element for the
hyperlinks (or a title computed from the link title).
The advantage of this method is that it'll always work, not break
existing cookies (if not combined with the solution for c) above), but
it will still need the array in the script. An additional advantage is
that all stylesheets will be used that are present in the DOM via link
elements. So each page can have individual styles assigned to it; the
master script file styleswitcher.js needs descriptions for all of them.
Comments, suggestions, preferences?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
-----END PGP SIGNATURE-----
More information about the website