[thelist] javascript browser/platform/css help needed

miinx lists at miinx.com.au
Mon Oct 28 22:43:00 CST 2002


Marlene Bruce wrote:
> Since I'm not up on Javascript, what I want this to do is:
> * For Win IE 4 and up, and Mac IE 5 and up, to serve the font sizes
> as indicated (no modifiers).
> * For Win Netscape 4, to serve the font sizes with a +1 modifier.
> * For Mac IE 4 and Netscape 4, to serve the font sizes with a +3 modifier.
> * For non-IE/Netscape browsers (Opera, iCab, etc.), to serve the font
> sizes as indicated (no modifiers).
>

Hi Marlene,

// modifying the first bit:
var NS4 = (document.layers);
var IE4 = (document.all);
var ver4 = (NS4 || IE4);
var IE5 = (IE4 && navigator.appVersion.indexOf("5.")!=-1);
var isMac = (navigator.appVersion.indexOf("Mac") != -1);
var isWin = (navigator.appVersion.indexOf("Win") != -1);

var style_sheet=0;
var font_1=7;
var font_2=10;
var font_3=11;
var font_4=12;
var font_5=16;
var font_6=18;
var modifier=0;

// For Win Netscape 4, to serve the font sizes with a +1 modifier.
if (NS4 && isWin) {
     modifier = 1;
}

// For Mac IE 4 and Netscape 4, to serve the font sizes
// with a +3 modifier.
if (isMac && (IE4 || NS4)) {
     modifier = 3;
}

// for anything other browsers you don't need to do anything.

// write your styles - I've split this over a few more
// lines here purely for clarity
document.write('<style type="text/css">\n');
document.write('p, body, td, ul, ol, li\n{');
document.write('\nfont-family: Verdana, Arial, Geneva, sans-serif;');
document.write('\nfont-size:');
document.write(font_4 + modifier);
document.write('px;\ncolor: #000000;\n}\n');
document.write('</style>\n');

hth :)
Karen
-------
Miinx Design & Development
e :: karen at miinx.com.au
p :: 0413.880.302
w :: www.miinx.com.au





More information about the thelist mailing list