SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2000
    Location
    Somewhere
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Style based on browser

    Hi,

    How can I get a style sheet to load up based upon browser type?

    The site I am currently working on displays as intended in IE6, NS6, and Opera 5. IE5 does not display the site as well and I would like to load up an IE5 specific stylesheet for users of the browser.

    Thanks.

  2. #2
    SitePoint Zealot
    Join Date
    Nov 2001
    Location
    Earth
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is your site just HTML or PHP or ASP??

    Different methonds depending on how it is coded.

    Frank
    http://www.serverexpert.com/ Discuss servers and the software that makes them work.
    http://www.webmasters-resources.com/ Resources for webmasters.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2000
    Location
    Somewhere
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ffeingol,

    The site is mostly html, with some php thrown in for file includes.

  4. #4
    SitePoint Zealot
    Join Date
    Nov 2001
    Location
    Earth
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is an article from www.phpbuilder.com that gives an example of how to do it with PHP.

    It's just one example.

    Frank
    http://www.serverexpert.com/ Discuss servers and the software that makes them work.
    http://www.webmasters-resources.com/ Resources for webmasters.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2000
    Location
    Somewhere
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks.

    That link was pretty interesting.
    While I'm sure I could figure it out (i'm not a php expert yet)I'd like to do something a bit simpler.

    Any ideas? Thanks again for your help.

  6. #6
    SitePoint Member
    Join Date
    Dec 2001
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JavaScript

    If you're really against doing a browser detection with server-side scripting, you could use JavaScript to do it. Mozilla has a little browser-detection script that you can download at http://www.mozilla.org/docs/web-deve...wser_type.html. You could put a chunk of code that looks something like this in your head tags:

    <script lanugage="JavaScript" type="text/css" src="filelocation.js">
    <!--
    if (is_nav4up || is_ie3up) {
    document.write(<link rel="stylesheet" type="text/css" href="somefile.css">);
    else {
    document.write(<link rel="stylesheet" type="text/css" href="someotherfile.css">);
    }
    // Hide from older browsers -->
    </script>

    Please forgive any errors as I am not very experienced in using JavaScript.

    Hope this helps and good luck!
    Simplicity is priceless.

    My fledgling site: http://arriya.netfirms.com/cgi-bin/index.cgi

  7. #7
    SitePoint Guru
    Join Date
    Dec 2001
    Location
    San Diego, CA
    Posts
    617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know ESPN.COM uses this. Check their code to see how they did it. I always learn by looking at others code.

    EDIT: actually, don't look at their code, it's chaos, hah

  8. #8
    No. Phil.Roberts's Avatar
    Join Date
    May 2001
    Location
    Nottingham, UK
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Browser-sniffing methods are always going to be inherently flawed. Most modern browsers give users the option of spoofing their user-agent header, which would completly screw up and sniffer code. Also if you dont have Javascript enabled then a Jscript sniffer wont work at all.....
    THE INSTRUCTIONS BELOW ARE OLD AND MAY BE INACCURATE.
    THIS INSTALL METHOD IS NOT RECOMMENDED, IT MAY RUN
    OVER YOUR DOG. <-- MediaWiki installation guide


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •