Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Junior Member
    Join Date
    Dec 2007
    Posts
    12
    Member #
    16242
    Hi I was wondering if someone could help me out. I need to link a different CSS style sheet to IE6 and 7. I have java script for linking it to FF Safari and Opera. I was wondering if anyone knew how i could use the script for IE. The code will be below.

    Code:
    <!--
    var safari = false;
    var opera = false;
    var firefox = false;
    var agent = navigator.userAgent.toLowerCase();
    
    if (agent.indexOf("safari") != -1){
    //code to show Safari Stylesheet
    document.write('<link rel="stylesheet" type="text/css" href="CSS/safari.css" \/>');
    }
    else if(agent.indexOf("opera") != -1){
    //code to show Opera Stylesheet
    document.write('<link rel="stylesheet" type="text/css" href="CSS/opera.css" \/>');
    }
    else if(agent.indexOf("firefox") != -1){
    //code to show FireFox Stylesheet
    document.write('<link rel="stylesheet" type="text/css" href="CSS/firefox.css" \/>');
    }
    //-->
    /edit
    I've tried putting ie6 and ie7 and plain old ie, none of those work.

  2.  

  3. #2
    Senior Member ravensjeff's Avatar
    Join Date
    Aug 2007
    Location
    Maryland
    Posts
    125
    Member #
    15751
    I think the IE User Agents are in the format MSIE 7.0 and MSIE 6.0, etc.

    I;m sure there is a reason you are doing this but it's going to be awfully difficult to feed a stylesheet for every browser out there.

  4. #3
    Junior Member
    Join Date
    Dec 2007
    Posts
    12
    Member #
    16242
    Quote Originally Posted by ravensjeff
    I think the IE User Agents are in the format MSIE 7.0 and MSIE 6.0, etc.

    I;m sure there is a reason you are doing this but it's going to be awfully difficult to feed a stylesheet for every browser out there.
    Well the problem is i need to have a website that is compatible to Chrome, MSIE 6, 7, and 8, firefox, safari, and opera. It's a requirement for a class I'm taking and if I don't have all these things or at least IE 6 , 7, ff, and safari then I may fail.

    Also I tried MSIE 6.0 and that didn't work. I'm gonna have to try it 7.0 once I get 6.0 working.

  5. #4
    Junior Member
    Join Date
    Apr 2009
    Posts
    4
    Member #
    18825
    I think your process so complex for browsers.

    You can use this process in HTML tag. No need javacript
    Code:
    <!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="CSS/ie6.css" />
    <![endif]-->
    
    <!--[if IE 7]>
    <link rel="stylesheet" type="text/css" href="CSS/ie7.css"/>
    <![endif]-->

  6. #5
    Junior Member
    Join Date
    Dec 2007
    Posts
    12
    Member #
    16242
    Quote Originally Posted by pakhee
    I think your process so complex for browsers.

    You can use this process in HTML tag. No need javacript
    Code:
    <!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="CSS/ie6.css" />
    <![endif]-->
    
    <!--[if IE 7]>
    <link rel="stylesheet" type="text/css" href="CSS/ie7.css"/>
    <![endif]-->
    Ok, well I got it to work for firefox, but the IE 6 part isn't working. I put the code in the header and it worked for FF but I also modified it to make it a bit less code, and it looks a bit better. Either way just using the code you gave me didn't work.

    Code:
    <!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="CSS/ie6.css" />
    <![else if IE 7]>
    <link rel="stylesheet" type="text/css" href="CSS/ie7.css" />
    <![else if firefox]>
    <link rel="stylesheet" type="text/css" href="CSS/firefox.css" />
    <![else if safari]>
    <link rel="stylesheet" type="text/css" href="CSS/safari.css" />
    <![else if opera]>
    <link rel="stylesheet" type="text/css" href="CSS/opera.css" />
    <![endif]-->

  7. #6
    Junior Member
    Join Date
    Apr 2009
    Posts
    4
    Member #
    18825
    Quote Originally Posted by Mylegiscramped
    Ok, well I got it to work for firefox, but the IE 6 part isn't working. I put the code in the header and it worked for FF but I also modified it to make it a bit less code, and it looks a bit better. Either way just using the code you gave me didn't work.

    Code:
    <!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="CSS/ie6.css" />
    <![else if IE 7]>
    <link rel="stylesheet" type="text/css" href="CSS/ie7.css" />
    <![else if firefox]>
    <link rel="stylesheet" type="text/css" href="CSS/firefox.css" />
    <![else if safari]>
    <link rel="stylesheet" type="text/css" href="CSS/safari.css" />
    <![else if opera]>
    <link rel="stylesheet" type="text/css" href="CSS/opera.css" />
    <![endif]-->
    This hack only IE not others browser.
    Code:
    <!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="CSS/ie6.css" />
    <![endif]-->
    
    <!--[if IE 7]>
    <link rel="stylesheet" type="text/css" href="CSS/ie7.css"/>
    <![endif]-->
    Why you need every browser separate CSS?

    N.B If your HTML code is good then no need hack except IE6.

    Your JavaScript Solution.. you can try this
    Code:
    var arVersion = navigator.appVersion.split("MSIE")
       
    var version = parseFloat(arVersion[1])
    if (version ==6)
    {
    <link rel="stylesheet" type="text/css" href="CSS/ie6.css"/>
    }

  8. #7
    Junior Member
    Join Date
    Dec 2007
    Posts
    12
    Member #
    16242
    Ok well i took out all code linking the CSS sheet to the page completely and Firefox Safari and Opera still work fine, but IE doesn't work. Where exactly do I put the following code?

    Code:
    <!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="CSS/ie6.css" />
    <![endif]-->
    <!--[if IE 7]>
    <link rel="stylesheet" type="text/css" href="CSS/ie7.css"/>
    <![endif]-->
    Also, like i said in an earlier post I need cross browser compatabilty because it's required for the project in my class.

  9. #8
    Junior Member
    Join Date
    Apr 2009
    Posts
    4
    Member #
    18825
    Code:
    <!--
    var safari = false;
    var opera = false;
    var firefox = false;
    var agent = navigator.userAgent.toLowerCase();
    
    if (agent.indexOf("safari") != -1){
    //code to show Safari Stylesheet
    document.write('<link rel="stylesheet" type="text/css" href="CSS/safari.css" \/>');
    }
    else if(agent.indexOf("opera") != -1){
    //code to show Opera Stylesheet
    document.write('<link rel="stylesheet" type="text/css" href="CSS/opera.css" \/>');
    }
    else if(agent.indexOf("firefox") != -1){
    //code to show FireFox Stylesheet
    document.write('<link rel="stylesheet" type="text/css" href="CSS/firefox.css" \/>');
    }
    //-->
    var arVersion = navigator.appVersion.split("MSIE")
       
    var version = parseFloat(arVersion[1])
    if (version ==6)
    {
    <link rel="stylesheet" type="text/css" href="CSS/ie6.css"/>
    }
    if (version ==7)
    {
    <link rel="stylesheet" type="text/css" href="CSS/ie7.css"/>
    }
    Just try this...

    Code:
    <!--
    var safari = false;
    var opera = false;
    var firefox = false;
    var agent = navigator.userAgent.toLowerCase();
    
    if (agent.indexOf("safari") != -1){
    //code to show Safari Stylesheet
    document.write('<link rel="stylesheet" type="text/css" href="CSS/safari.css" \/>');
    }
    else if(agent.indexOf("opera") != -1){
    //code to show Opera Stylesheet
    document.write('<link rel="stylesheet" type="text/css" href="CSS/opera.css" \/>');
    }
    else if(agent.indexOf("firefox") != -1){
    //code to show FireFox Stylesheet
    document.write('<link rel="stylesheet" type="text/css" href="CSS/firefox.css" \/>');
    }
    //-->
    If this your earlier code OK

    then only use below code in your <head></head>
    Code:
    <!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="CSS/ie6.css" />
    <![endif]-->
    
    <!--[if IE 7]>
    <link rel="stylesheet" type="text/css" href="CSS/ie7.css"/>
    <![endif]-->

  10. #9
    Senior Member ravensjeff's Avatar
    Join Date
    Aug 2007
    Location
    Maryland
    Posts
    125
    Member #
    15751
    If you teacher is any good, he's not going to look real favorable at feeding separate stylesheets to all of these browsers. You should definitely work on making your code work universally. There are very few times when I need to use any hacks whatsoever to get my sites to appear universal in all those browsers. The only exception would be the transparent png fix for IE6. Occasionally, maybe another work around for IE6. But for the most part, if your site is appearing differently in Firefox than Safari, or Firefox than IE7 in most cases, your code likely doesn't validate. Run your code through validation and see if you can fix those errors. That should solve a lot of the problem with your rendering differences.

  11. #10
    Junior Member
    Join Date
    Dec 2007
    Posts
    12
    Member #
    16242
    ok well, I redid some coding and got them all to work properly, ubt like Pahkee said the png issue is prevalent. I'll post my code for where I put the code for the png fix.
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
    
    <!--[if lt IE 8]>
    <script src="http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE8.js" type="text/javascript"></script>
    <![endif]-->
    
    <link href="/CSS/firefox.css" rel="stylesheet" type="text/css" />
    
    
    
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    I think I put it in the right place, but it still doesn't seem to work. Do I need to do anything other than putting that code there?


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:09 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com