[thelist] javascript browser/platform/css help needed
Marlene Bruce
marlene at underoneleaf.com
Mon Oct 28 19:50:01 CST 2002
(forgot I'm not subscribed from work ... sorry if you get two of these)
Hi folks,
I have a Javascript which detects browser/platform and then serves
the appropriate font sizes from within the Javascript. A former
co-worker made it for me a year or so ago, and now I need to modify
it for a new use.
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).
Below is a snippet, with only one of the style sheet definitions
included (as an example).
Can someone help me modify what I have to achieve what I want to do?
--------------------
<!-- hide script from old browsers
var BrowserType='NS';
var Platform='Win';
var ver_str = navigator.appVersion;
var ver_info = ver_str.split(';');
var version=4;
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;
if(navigator.appName == 'Microsoft Internet Explorer')
{BrowserType = 'IE';}
if(navigator.platform.substr(0,3)=='Mac')
{Platform = 'Mac';}
if(BrowserType=='IE')
{version = ver_info[1].substr(6,ver_info[1].length);}
else
{version = parseFloat(ver_str);}
if(Platform == 'Win')
{
if(BrowserType == 'NS')
{
if(version < 5)
{modifier=1;}
}
}
else
{
if(BrowserType == 'NS')
{
if(version < 5)
{modifier=1;}
}
}
document.write('<style type="text/css">\n');
document.write('p, body, td, ul, ol, li\n{\nfont-family: Verdana,
Arial, Geneva, sans-serif;\nfont-size:
'+(font_4+modifier)+'px;\ncolor: #000000;\n}\n');
document.write('</style>\n');
//end hiding script from old browsers -->
--------------------
Thanks in advance,
Marlene
More information about the thelist
mailing list