Web Analytics Made Easy -
StatCounter Browser dependent stylesheet - CodingForum

Announcement

Collapse
No announcement yet.

Browser dependent stylesheet

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    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.

    Comment


    • #3
      Fantastic! And I thought I knew all the HTML there is to know

      Thanks!
      I know that I know nothing

      Comment


      • #4
        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.

        Comment


        • #5
          Are there any other "proprietary" tricks out there?
          I know that I know nothing

          Comment


          • #6
            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"

            Comment


            • #7
              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.

              Comment

              Working...
              X