Results 1 to 5 of 5

Thread: Browser Detect for PNG/ GIF Alternatative

  1. #1
    Join Date
    Aug 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Browser Detect for PNG/ GIF Alternatative

    Hi,


    I am using PNG-24 images with alpha transparencies on a site. Since Internet explorer doesn't support the alpha transparencies, I would like to display GIF alternatives for IE. Where can I find a script that will detect the browser and display the appropiate image formats? I'm not an expert with Javascript, so a site with a tutorial would be appreciated but any help would also be greatly appreciated. The link to the site I am working on is lifesizeht.com/home.html


    Sharez

    P.S. I did a lot of research and I found a lot of scripts that show how to display the PNG in IE using a filter but I can't get any of them to work properly so I feel that using GIF alternatives would be an easier method.

  2. #2
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    Well, you could use IE7(click the link,it's not what you think) but conditional comments are the best tool for the job(if somewhat harder)

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    P.S. I did a lot of research and I found a lot of scripts that show how to display the PNG in IE using a filter but I can't get any of them to work properly so I feel that using GIF alternatives would be an easier method.
    It may be easier, but it wouldn't be as good. You'd have to resort to "downlevel-revealed" conditional comments at best, which would render your page invalid.
    If you can get one of those filter hacks working, it's best to do so:
    Code:
    <!-- Head: -->
    
    <!--[if IE]><style type="text/css">
    #alphaImage1 {
      filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='firstAlphaImage.png', sizingMethod='scale');
    }
    </style><[endif]-->
    
    <style type="text/css">
    #alphaImage1 {
      height: 100px;
      width: 100px;
      background-image: url(firstAlphaImage.png) !important;
      background-image: none;
    }
    </style>
    
    <!-- Body: -->
    
    <div id="alphaImage1"></div>
    /EDIT: From that link, LOL.
    Last edited by Twey; 08-15-2006 at 09:04 PM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by SharezS
    I am using PNG-24 images with alpha transparencies on a site. Since Internet explorer doesn't support the alpha transparencies, I would like to display GIF alternatives for IE.
    Reasonable enough.

    Where can I find a script that will detect the browser and display the appropiate image formats?
    You don't. Instead, you determine what the browser supports and serve the appropriate type.

    The Accept HTTP request header indicates MIME types that the user agent supports. Of image/png and image/gif, IE only sends the latter, whilst Opera, Mozilla, and Konqueror send both and support alpha transparency.

    Read up on how to perform content negotiation on your server. If you have a server-side programming language available, you could also use that.

    P.S. I did a lot of research and I found a lot of scripts that show how to display the PNG in IE using a filter but I can't get any of them to work properly so I feel that using GIF alternatives would be an easier method.
    Using filters also depends upon client-side scripting (and possibly ActiveX; I've never actually checked). Though the GIF might not look quite as nice, it's more reliable. That said, there's no real harm in using both, together.

    Mike

  5. #5
    Join Date
    Aug 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you all for your help. I decided to optimize the images in Fireworks by converting them to PNG-8 with alpha transparency. It looks great in Firefox (same as PNG-24) and it works in IE (doesn't look as good but it works).


    Thanks again,


    Sharez

Bookmarks

Posting Permissions

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