SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jun 2000
    london, UK
    0 Post(s)
    0 Thread(s)
    Hope somebody can help with the follwing:

    I am trying to use the script below to detect whether the user is: a) using a Mac
    b) if he is using a PC whether he is using IE or netscape.

    This is so that I can implement different style sheets for NS/IE on PC and a different style sheet for mac.

    But it doesnt work - it is not even picking up my style sheets for the PC versions. All the paths are correct so it is not that.

    Hers's the script:

    if (navigator.appVersion.indexOf("Mac") != -1){
    document.write('<link rel="stylesheet" type="text/css" href="/bustrav/scripts/style_mac.css">')
    if (navigator.appVersion.indexOf("Win") != -1)&& (navigator.appName=="Microsoft Internet Explorer"){
    document.write('<link rel="stylesheet" type="text/css" href="/bustrav/scripts/style_ie.css">')
    else {
    document.write('<link rel="stylesheet" type="text/css" href="/bustrav/scripts/style_ns.css">')

    If anyone could shed any light on this for me I'd be really grateful!



  2. #2
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Lancaster, Ca. USA
    1 Post(s)
    0 Thread(s)
    Is this script place in the HEAD section of your page? If it is placed in the body section then the CSS won't effect the page until its reloaded if at all. My suggestion would be to use server side detection and build the page with the CSS include dynamically before the browser even sees it. You can do this in PERL, PHP and ASP.

    One of the best products available for server-side detection is called BrowserHawk. It is available in both ActiveX Component and Java Server Page formats so it should be usable on almost any server.

    Wayne Luke - Sitepoint Moderator/Internet Media Developer
    Digital Magician Studios - Making Magic with Web Applications


Posting Permissions

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