problem in applying platform specific css

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deepakNagpal
    New Member
    • Jul 2007
    • 15

    problem in applying platform specific css

    hi,

    this is deepak, i got stuck in a script where i want to apply a platform specific css. i will be greatful if anyone could help me out.

    My PHP code is:
    [code=php]
    <?php
    $agent = getenv("HTTP_US ER_AGENT");

    if (preg_match("/Win/i", "$agent")){
    $style = "win";
    //echo "matched window";
    }else if (preg_match("/Linux/", "$agent")){
    $style = "linux";
    //echo "matched linux";
    }
    $win_style = "
    <style1 type = \"text/css\">\n
    p, ul, ol, li {font family:Arial;fo nt-size:20pt;font-weight:normal;} \n
    h1 {font family:Arial;fo nt-size:16pt;font-weight:bold;}\n
    h2 {font family:Arial;fo nt-size:14pt;font-weight:bold;}\n
    strong {font family:Arial;fo nt-size:10pt;font-weight:bold;}\n
    em {font family:Arial;fo nt-size:10pt;font-style:italic;}\ n
    </style1>
    ";

    $linux_style = "
    <style1 type = \"text/css\">\n
    p, ul, ol, li {font family:Times;fo nt-size:10pt;font-weight:normal;} \n
    h1 {font family:Times;fo nt-size:18pt;font-weight:bold;}\n
    h2 {font family:Times;fo nt-size:16pt;font-weight:bold;}\n
    strong {font family:Times;fo nt-size:12pt;font-weight:bold;}\n
    em {font family:Times;fo nt-size:12pt;font-style:italic;}\ n
    </style1>
    ";
    ?>

    <html>
    <head>
    <title>Platfo rm Matching</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <?
    if($style == "win"){
    echo "$win_style ";
    $style = "$win_style ";
    }else if($style == "linux"){
    echo "$linux_sty le";
    $style = "$linux_sty le";
    }
    ?>
    <h1 align=center> This is a level 1 heading </h1>
    <h2 align=center> Look! a level 2 heading</h2>
    <p align=center> this a simple paragraph with some <strong> bold </strong> and <em> emphasized</em> text.</p>
    </body>
    </html>
    [/code]
    Last edited by pbmods; Jul 20 '07, 01:44 PM. Reason: Added CODE Tags
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Deepak, you've been on this site a little while. Long enough to know that you're supposed to use CODE tags when you post source code. Don't let me catch you posting code without CODE tags again.

    Also, moving out of the articles section.

    Comment

    Working...