I do not have a Mac so this is theoretical.
Look in the javascript variable self.navigator.platform
On a windows PC it contain something like 'Win32'
On a Mac I would expect something like 'MacOs___'
etc for linux or whatever.
the specific browser you find in self.navigator.userAgent
mine say: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3'
Rather messy, but the info is there so you can test
fx:
if ( 'Mac' == substring( self.navigator.platform, 0, 3 )
&& false !== strpos( self.navigator.userAgent, 'Firefox' ) //NB typefixed compare
)
{ // this is Firefox on Mac so build that class here
document.styleSheets[0].in
//add new rule to start of stylesheet
}
else
.... // build other rules similarly. And yes, as usual IE does it a bit different.
// read: http://www.javascriptkit.c
If the pags is generated serverside you can instead just fetch the useragent in a header and generate the appropriate stylesheet on the server.
regards JakobA
Main Topics
Browse All Topics





by: RedKelvinPosted on 2007-05-03 at 20:00:25ID: 19028591
You could use javascript to detect the browser and machine type js/detect. html
http://www.quirksmode.org/
Then based on the result attach the particular style sheet to the document, for that system.
This will of course require an individual .css file for each target system
eg
if (Firefox on Mac)
{
document.write("<link REL='STYLESHEET' TYPE='text/css' HREF='/firefoxMac.css' Title='MyStyle'>");
}
else if (Firefox on PC)
{
document.write("<link REL='STYLESHEET' TYPE='text/css' HREF='/firefoxPC.css' Title='MyStyle'>");
}
RedK