SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Sep 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need some help with my script

    I just got started with javascript, so go easy on me. This is probably going to have a total "duh" answer. Anyways, basically I have an external script that I copy and pasted from a tutorial, I know I won't learn much by doing this, and I'm using another script, which I wrote, that uses the 1st scripts elements.

    The main point to all this is to detect the client browser and based on the result provide a specific css file that works with the returned browser.

    I don't know wether to do something to include the main script or if I need to adjust something thats not right in my script. Heres my script:


    if ("BrowserDetect.browser == Safari") {
    document.write('<link type="text/css" href="style.css" />');
    }
    else if ("BrowserDetect.browser == Explorer") {
    document.write('<link type="text/css" href="style2.css" />');
    }
    else if ("BrowserDetect.browser == Firefox") {
    document.write('<link type="text/css" href="style3.css" />');
    }
    else {
    alert ("What browser are you using?!")
    }


    Thanks beforehand for your help! Although this is probably an easy question.

  2. #2
    SitePoint Evangelist
    Join Date
    Jul 2007
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have
    "BrowserDetect.browser == Safari"

    Should you have
    BrowserDetect.browser == "Safari"


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
  •