CSS selectors in web pages

Jeroen Coumans jeroen at linuxfromscratch.org
Sat Sep 18 00:40:25 PDT 2004


Nico R. said the following on 15-09-2004 17:04:

> The code may still be a bit buggy, as I just quickly learned a bit of
> DOM and ECMAScript/JavaScript to get this done. Hope it's all right.
> 
> I could not test this on many browsers, so you should do some testing
> before committing anything.
> 
> Have fun with it!

Thanks, it works in Mozilla at least! I'll test IE and Konqueror too. 
But first, can I make an enhancement request? Would it be difficult to 
make the script "plug & play"? I mean, so that it would walk the DOM, 
ask for all screen stylesheets and make add them itself? Or if there are 
no alternate stylesheets, that it would not display the switcher menu?

In pseudo-code, it would be something like this:

if no DOM then exit;
if no getElementById then exit;
query DOM; if no screen stylesheets then exit;
if screen stylesheet exist {
  if cookie {
	read cookie; set stylesheet }
    else set default stylesheet
  write <div id="styleswitcher"><ul>
  for each stylesheet $name, write <li>...</li>; done
write </ul></div>
done }

onclick set default style=clickstyle & set/adjust cookie

Thanks again!

-- 
Groeten/Greetings,
Jeroen Coumans
{faq,website}@linuxfromscratch.org
www.jeroencoumans.nl



More information about the website mailing list