DHTML Lab: HierMenus CENTRAL: Version 3.x FAQ #15 - dhtmlab.com
Frequently Asked Question #15
Entered: August 22, 2000
|The font size that I specify renders differently across platforms. For example, a 10pt font looks fine on Windows but it is too small on the Mac. Can I specify different font sizes for different platforms?|
Yes. In fact, you can easily make any of your in-page parameter variables platform or browser-specific.
Let's take font size as an example, since this is the variable that creates the most platform problems. It is one of our Global Parameter Variables, set in-page:
fntSiz = 10;
Earlier in our in-page script, we have declared variables that relate to browser, version and platform used:
NS4 = (document.layers); IE4 = (document.all); ver4 = (NS4 || IE4); IE5 = (IE4 && navigator.appVersion.indexOf("5.")!=-1); isMac = (navigator.appVersion.indexOf("Mac") != -1);
These variables are always available to us, and we can use them when declaring our Global Parameter Variables. For example, if we want Macintosh users to display menu items in a 12 point font, we can use this syntax:
fntSiz = isMac ? 12 : 10;
As we know, IE5 for Macintosh displays font sizes using the Windows standard, so you might want to exclude IE5Mac from the larger font size declaration:
fntSiz = (isMac && !IE5) ? 12 : 10;
Here are two more examples:
The font family assigned is the platform system font, giving the menus an OS-look:
fntFam = isMac ? "Chicago" : "MS Sans Serif";
IE for Windows allows authors to access the User-Defined System Colors. See our discussion in Column 24. In the example below, menus are created in the user's system colors for IEWin and in hard-coded colors for all other users.
backCol = (IE4 && !isMac) ? "menu" : "#CE9A9C"; overCol = (IE4 && !isMac) ? "highlight" : "maroon"; fntCol = (IE4 && !isMac) ? "menutext" : "black"; overFnt = (IE4 && !isMac) ? "highlighttext" : "white";
Produced by Peter Belesis and
All Rights Reserved. Legal Notices.
Created: Aug 22, 2000
Revised: June 26, 2001