Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Aug 2006
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Browser dependent stylesheet

    Internet Explorer keeps mucking up all the neat CSS that works fine in Firefox and Opera.
    Could someone suggest a script that would do something like this:

    Code:
    if browser IE then
    response.write
    <link rel="stylesheet" type="text/css" href="IE.css">
    else 
    response.write
    <link rel="stylesheet" type="text/css" href="normal.css">
    ASP only please, no javascript
    Thank you in advance!
    I know that I know nothing

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,611
    Thanks
    0
    Thanked 645 Times in 635 Posts
    IE provides a way to do it in HTML, no scripting of any sort required.

    Code:
    <link rel="stylesheet" type="text/css" href="normal.css">
    <!--[if IE]>
    <link rel="stylesheet" type="text/css" href="IE.css">
    <![endif]-->
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    New Coder
    Join Date
    Aug 2006
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Fantastic! And I thought I knew all the HTML there is to know

    Thanks!
    I know that I know nothing

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,611
    Thanks
    0
    Thanked 645 Times in 635 Posts
    It is an IE proprietary way of adding conditional statements into HTML. All other browsers just treat it as comments.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #5
    New Coder
    Join Date
    Aug 2006
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are there any other "proprietary" tricks out there?
    I know that I know nothing

  • #6
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here's what I use to deal with the dreaded 3px bug in IE

    #somecss {
    margin-left = 0px;
    }

    *html #somecss {
    margin-left = -3px;
    }

    Every browser but IE will use "#somecss" style properties, but IE will use the ones from "*html #somecss"

  • #7
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,611
    Thanks
    0
    Thanked 645 Times in 635 Posts
    Using two separate stylesheets and IE conditionals in the HTML you don't need to use hacks like that, you just put the IE code in the IE stylesheet to override the standard code.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

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