#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    Stockholm
    Posts
    1
    Rep Power
    0

    Question Re-direct browser for different CSS?


    Hello,

    I want to do a webpage that will have two stylesheets, one for IE browsers and the other for Netscape browser. How can I do this with two different .css files?

    I would like the browser to re-direct the user according to their browser.

    thanks in advice!

    /D'arcangelo
  2. #2
  3. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    It's not a redirect; you just need to link the page to the appropriate .css file. Here's one way:
    ______________________________________________________________________________________
    <html>
    <head><title>untitled</title>

    <script language="Javascript" type="text/javascript">

    var b = document.layers ? 'NS4' : document.all ? 'IE' :
    document.getElementById && !document.all ? 'NS6' : 'default';

    document.write('<LINK rel="stylesheet" type="text/css" href="'+ b + '_style.css">');

    </script>

    This will read into the document a .css file named "NS4_style.css" (or "IE_style.css"/"NS6_style.css"/"default_style.css") as needed. Change the filenames as desired. You can get much more granular (discriminating) with this - detect Mac platforms as well - but this is the basic principle.

    http://www.richinstyle.com/mastercla...ssbrowser.html
    Last edited by adios; July 7th, 2001 at 07:54 PM.

IMN logo majestic logo threadwatch logo seochat tools logo