[thelist] Theme switcher and browser differences

Liorean Liorean at user.bip.net
Wed Feb 27 15:14:00 CST 2002


<crosspost list="css-discuss" > Sorry to those of you who read both lists.
</crosspost>



In a project of mine, I've created a theme switcher based on ALA's style
switcher, but using my own cookie library. (Requires JS, Cookies and
Stylesheets to be turned on.)


Now, I'm having problems with ALL browsers I've tested it on in some way or
the other.

1. Moz 0.9.6 Mac and 0.9.8 Win, probably the others as well:
    The standard stylesheet is applied at first entry, but the font size of
the header is normal, even though it's placed in a h1 tag. What can I do to
get Moz to use the right font size? (This problem also appears when I take
all my scripts out and use Moz's built-in style switcher)

2. Ie 5.1 Mac, Ie 6.0 Win, Ns 6.2 Win (strangely, Ns6.2 behaves more like
IE Win than like Moz):
    The standard stylesheet isn't applied at first entry. Anyone able to
explain why?

3. Ie 6.0 Win, Ns6.2, Moz 0.9.6 Mac:
    When you change stylesheet, the background colour is changed only for
the canvas (The Horizontal space covered by HTML elements). In Ie the
background changes after covering the window with another window and then
bringing it to front, while Ns6.2 keeps it covering just the canvas. Why do
they behave like that?

4. Ie 5.1 Mac:
    Header background and border are missing in action.

5. Opera 6:
    Can't use the theme switcher due to lack of JS/DOM support.

6. Ns 4, Ie 5.0 Win, Ie 5.5 Win:
    Can't read the themes due to lack of css2 support. Suits them well!
<grin />


The correct behavior:
- On first entry the site uses the White-Blue theme. (Moz 0.9.8, Opera 6
does so)
- No script errors are reported on changing stylesheet.
- The entire viewport is filled by the background color, not only the canvas.
- The font sizes are rendered as specified.


Can anyone help me with those problems?
Also, if anyone want to help, I'd like to know how it behaves in IE 5.0 Mac
and Konqueror.


Oh, and the URL: <http://www20.brinkster.com/liorean/wcd/new/index.html>



And, just a penalty for crossposting:
<tip type="JavaScript" author="Liorean">
If you in a function use complex string handling like multiple switch,
if-else if-else or loop statements containing .indexOf() and .substring(),
you would almost certainly be able to do things more efficiently using
RegExp. Take a look at this cookie handler (created by Chris Nott of
<http://dithered.com/> ) for instance:

// Retrieve a named cookie value
function getCookie(name) {
	var dc = document.cookie;

	// find beginning of cookie value in document.cookie
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	}
	else begin += 2;

	// find end of cookie value
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) end = dc.length;

	// return cookie value
	return unescape(dc.substring(begin + prefix.length, end));
}

that could easily be rewritten using RegExp to a smaller and faster function:

function getCookie(name) {
   var re=new RegExp(name+'=([^;]*);?');
   var r=re.exec(document.cookie)||[];
   return unescape(r.length>1?r[1]:null);
}
</tip>

Thanks in advance,
// Liorean, grateful for help with these nasty problem.




More information about the thelist mailing list