1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Browser Ident Stylesheet Trick

Discussion in 'Web Design and Development (archive)' started by FattyMembrane, Feb 29, 2004.

  1. macrumors 6502a

    FattyMembrane

    #1
    i spent 3 hours yesterday trying to get the website for a club of which i'm a member to work properly in IE. The site rendered fine in mozilla/khtml but of course IE has serious css bugs and the page looked like crap. i ended up having to create a separate stylesheet for IE and after pilfering some code from various resources on the net, i came up with a little javascript that you can put in the <head> of your file that will give IE a special stylesheet. this is nothing groundbreaking, but i thought it might be helpful to those of you struggling to keep your site IE compliant.

    Code:
    <script type="text/javascript">
    var ua = navigator.userAgent.toLowerCase();
    this.isIE = (ua.indexOf('msie') != -1);
    
    if (this.isIE)
    {document.write("<link rel='stylesheet' type='text/css' href='iestylesheet.css' />");}
    else
    {document.write("<link rel='stylesheet' type='text/css' href='stylesheet.css' />");}
    </script>
     
  2. macrumors 68030

    mnkeybsness

    #2
    I have to load a javascript file to make Internet Explorer allow alpha transparency with PNG-24 images. Instead of having javascript to check if it is IE, you can use something with this style...
    Code:
    <!--[if gte IE 5.5000]>
    <script type="text/javascript" src="http://www.yoursite.com/link-to-javascript"></script>
    <![endif]-->
    This works really well because it will just be read as a comment by any browser except IE 5.5+. You could also do something similar with CSS.
     
  3. macrumors 65816

    mrjamin

    #3
    wow!! that's cool!
     

Share This Page