CSS selectors in web pages
n-roeser at gmx.net
Mon Sep 20 06:20:38 PDT 2004
-----BEGIN PGP SIGNED MESSAGE-----
Jeroen Coumans wrote:
> Nico R. said the following on 19-09-2004 19:33:
> Well, the tooltip is optional and extra, so I'd have no problem if it
> were optional. The only relevant information which could be used would
> be the filename of the stylesheet. But no title is OK too.
Aaah, that was a great idea! :-)) See the attached new patch. It
obsoletes the first one I sent and should be applied instead of it. It
still changes scripts/styleswitcher.js and templates/template.html
I used a trick to put all information into the DOM - and it doesn't even
look that bad in the browser menus. Only the square brackets could be
changed into round ones, that might look better. Opinions?
> Breaking the cookies: we'd only change names if we switch to the new
Much has changed, but old cookies should still work nicely. Please
verify that on a test system.
> Would it also be possible to determine where in the page that the
> stylesheet would be placed? Perhaps by some <div id=""> which is in
> the page?
Sure. At the moment, an existing styleswitcher is replaced, if found,
but that's rather a (wanted) side effect; it should usually be created
by the script itself. By changing a few lines, it would be possible to
insert the styleswitcher ul element into a specific element with an id
(or even without, but that's rather tricky and requires that the script
has rough knowledge of the document structure of the documents).
>> 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).
> As long as it's only a fallback, I don't have a problem with it.
That's not even necessary in the new version. :-)
>> 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.
Ditto, not needed anymore.
Currently, pages with individual (but selectable) stylesheets don't make
much sense, since they will be disabled on entering a new page. But
that can be modified if need arises. We'll see later when the Wiki
version of the website is ready for going into production or deeper
The script tests for the presence of the 'media' attribute of the 'link'
elements, and for its value containing 'screen'. This should be
considered a feature (though we could implement selectable print style
sheets, too). It is *not* possible to use selectable scripts for media
type 'screen' without explicitly specifying this, e.g. by using no
'media' element or by using 'media="all"'. This is a
bug^H^H^Hlimitation in the script (which could be fixed if someone is
too bored or annoyed by this).
Please test the new version extensively and in different browsers,
because my testing possibilities on this system are currently a bit too
limited. I stumbled across one annoyance when loading a page for the
first time, but this seemed to be a browser bug to me, and I could not
safely reproduce it.
Try changing a few style sheets and keep an eye on the style selector.
It should change automagically.
Would be nice if you could also test with different numbers of style
sheets, e.g. 0, 1, 2, 3, >3. I didn't have the time to do so...
Oh, and feel free to remove some or all of the comments I inserted into
the code. I just added them to make it a bit easier for everybody to
get an idea of what the script is doing.
Hope you like it,
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2698 bytes
Desc: not available
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the website