Omni Systems, Inc.

  

Mif2Go User's Guide, Version 33u53

  

Valid HTML 4.01!

 

Made with Mif2Go

21 Setting up CSS for HTML > 21.6 Linking to alternate CSS files > 21.6.1 Selecting a CSS file at run time


21.6.1 Selecting a CSS file at run time

CSS support is a mixed bag; a lot depends on exactly which browsers, and which versions of them, you need to support. You might need to autodetect the browser and choose from different CSS files at run time, using a macro instead of a fixed link, to reference JavaScript code that detects the type of browser in use and selects an appropriate CSS file. For example:

[CSS]

WriteCssLink=Yes

CssBrowserDetect=<$SelectCSS1>

As an alternative:

[CSS]

WriteCssLink=No

[Inserts]

Head=<$SelectCSS1>

Provide the referenced macro:

[SelectCSS1]

; Include here the JavaScript from m2hmacro.ini

Sample macro [$SelectCSS1] contains JavaScript to detect several popular browsers. This macro, and an alternate, [$SelectCSS2], are included in file m2hmacro.ini, in your Mif2Go distribution folder. You can copy m2hmacro.ini file to the project folder, or just copy the macro definition into the configuration file for your project; see §27.1.1.2. You can modify the macro definition as needed; consult a JavaScript reference for syntax.



21 Setting up CSS for HTML > 21.6 Linking to alternate CSS files > 21.6.1 Selecting a CSS file at run time