You are here: irt.org | FAQ | JavaScript | Misc | Q351 [ previous next ]
You can detect a Mac using:
<script language="JavaScript"><!-- if (navigator.appVersion.indexOf('Mac') != -1) alert('Mac') //--></SCRIPT>
You can combine this with a basefont tag:
<basefont color=color face=string id=string size=string title=string >
to create:
<html> <head> <script language="JavaScript"><!-- if (navgator.appVersion.indexOf('Mac') != -1) document.write('<basefont size="3">') else document.write('<basefont size="2">') //--></script> </head> <body> ... </body> </html>
This has been reported to work, although not for text in table cells. Whilst you could add JavaScript code within every table cell to control the font size, this will cause problems in other browsers that choke on JavaScript code in table cells unless the entire row is output within JavaScript.
The only solution I can think of involves using Cascading Style Sheets - which will only work in Netscape Navigator 4+ and Internet Explorer 4+:
<html> <head> <script language="JavaScript"><!-- if (navgator.appVersion.indexOf('Mac') != -1) document.write('<link rel="stylesheet" href="mac.css" type="text/css">') else document.write('<link rel="stylesheet" href="default.css" type="text/css">') //--></script> </head> <body> ... </body> </html>
And then in mac.css specify larger font sizes than in default.css:
// mac.css P, BR, UL, OL, TD, TH, LI { color: black; font-family: Arial, Helvetica, serif; font-size:large; }
// default.css P, BR, UL, OL, TD, TH, LI { color: black; font-family: Arial, Helvetica, serif; font-size:medium; }