IE a pain in the ass again -.-

Discussion in 'OT Technology' started by Zappy, Aug 9, 2007.

  1. Zappy

    Zappy New Member

    Joined:
    Dec 6, 2006
    Messages:
    512
    Likes Received:
    0
    OK my mom is starting a small business and she wants me to do her website, so i been working some stuff up.

    http://www.charmzalot.com

    ATM its working in opera and nothing else, i was trying to use some javascript my friend gave me but when it comes to js im a total noob.

    <script language="javascript">
    if (navigator.appName == "Microsoft Internet Explorer")
    {
    cssobject.href="ie.css";
    }
    if (navigator.appName == "Mozilla Firefox")
    {
    cssobject.href="ff.css";
    }
    if (navigator.appName == "Opera")
    {
    cssobject.href="op.css";
    }
    </script>

    The problem is when i change somthing in any of the CSS files it does like nothing which makes no sense sense all of them go to somthing and the opera one needs its info from some where, ima keep working on it but if anyone can help it would be very nice.
     
  2. MrBrotato

    MrBrotato New Member

    Joined:
    Sep 7, 2005
    Messages:
    5,558
    Likes Received:
    0
    Wow, more complicated than it needs to be. And what if it is none of those 3?
     
  3. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    yea, very lame. create a single stylesheet, and you can implement "hacks" on an as-needed basis and only if absolutely required.
     
  4. ryanisnan

    ryanisnan New Member

    Joined:
    Jul 26, 2007
    Messages:
    29
    Likes Received:
    0
    I don't know much about JS but I do know that using navigator.appName is a bad way to go.

    Try using something like this:

    Code:
    // Firefox Version Requirements
    var requiredFirefoxVer = 2.0;
    // MSIE Version Requirements
    var requiredMSIEVer = 7.0;
    var initString = navigator.userAgent;
        
    if (navigator.userAgent.indexOf("Firefox")!=-1) {    
       var startPoint=navigator.userAgent.indexOf("Firefox")+8;
       var verLength = navigator.userAgent.length;
       var tempString =initString.substring(startPoint,startPoint+verLength);
       tempString = parseFloat(tempString);
       
       if (tempString >= requiredFirefoxVer) {
           // this version of firefox is sufficient
       } else {
          // this version of firefox is out of date
       }
    } else if (navigator.userAgent.indexOf("MSIE")!=-1) {
       var startPoint = navigator.userAgent.indexOf("MSIE")+5;
       var verLength = 3;
       var tempString = initString.substring(startPoint,startPoint+verLength);
       tempString = parseFloat(tempString);
       
       if (tempString >= requiredMSIEVer) {
            // this version of IE is sufficient
       } else {
            // this version of IE is out of date
       } 
    } else {
       // their browser is not supported
    }
    
    This is a little longer but it adds a pretty easy way to check certain versions.
     
  5. fishbulb

    fishbulb Active Member

    Joined:
    Oct 29, 2001
    Messages:
    6,848
    Likes Received:
    4
    Location:
    md
    Shoot for this method and use this CSS browser selector is absolutely necessary http://rafael.adm.br/css_browser_selector/
     
  6. ryanisnan

    ryanisnan New Member

    Joined:
    Jul 26, 2007
    Messages:
    29
    Likes Received:
    0

Share This Page