• Resolved Jimmy

    (@jayem82)


    My page still looks kinda funny when viewed on Explorer 6 and below. The earlier versions of IE cannot handle transparent png images correctly. I have fixed this issue with this javascript:

    function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
    {
    var arVersion = navigator.appVersion.split(“MSIE”)
    var version = parseFloat(arVersion[1])
    if ((version >= 5.5) && (document.body.filters))
    {
    for(var i=0; i<document.images.length; i++)
    {
    var img = document.images[i]
    var imgName = img.src.toUpperCase()
    if (imgName.substring(imgName.length-3, imgName.length) == “PNG”)
    {
    var imgID = (img.id) ? “id='” + img.id + “‘ ” : “”
    var imgClass = (img.className) ? “class='” + img.className + “‘ ” : “”
    var imgTitle = (img.title) ? “title='” + img.title + “‘ ” : “title='” + img.alt + “‘ “
    var imgStyle = “display:inline-block;” + img.style.cssText
    if (img.align == “left”) imgStyle = “float:left;” + imgStyle
    if (img.align == “right”) imgStyle = “float:right;” + imgStyle
    if (img.parentElement.href) imgStyle = “cursor:hand;” + imgStyle
    var strNewHTML = “<span ” + imgID + imgClass + imgTitle
    + ” style=\”” + “width:” + img.width + “px; height:” + img.height + “px;” + imgStyle + “;”
    + “filter:progid:DXImageTransform.Microsoft.AlphaImageLoader”
    + “(src=\'” + img.src + “\’, sizingMethod=’scale’);\”></span>”
    img.outerHTML = strNewHTML
    i = i-1
    }
    }
    }
    }
    window.attachEvent(“onload”, correctPNG);

    With this javascript all the png images are fixed as long as they are not set as backgrounds. But my page has a jpg body background and png backgrounds set in divs. Does anyone know a good javascript that fixes my div background?

    For example this is the code for my #page

    <style type=”text/css” media=”screen”>

    <?php
    // Checks to see whether it needs a sidebar or not
    if ( !$withcomments && !is_single() ) {
    ?>
    #page { background: url(“<?php bloginfo(‘stylesheet_directory’); ?>/images/bg-<?php bloginfo(‘text_direction’); ?>.png”) repeat-y top; border: none; }
    <?php } else { // No sidebar ?>
    #page { background: url(“<?php bloginfo(‘stylesheet_directory’); ?>/images/bgwide.png”) repeat-y top; border: none; }
    <?php } ?>

    </style>

    It shows up with the ugly light blueish instead of transparent only in IE 6.0 and maybe below versions as well.

    View my page https://www.jayem.se in IE 6.0 and you will understand what I need to fix. Look for the light blue border around the content.

Viewing 1 replies (of 1 total)
  • Thread Starter Jimmy

    (@jayem82)

    I just found another javascript to help me with IE 6.0 and below.

    The bgsleight is working good. It’s importent to add position: relative; to all div in css for the links not to go dead.

    Also in your head html remember to use the <!–[if lte IE 6]> and <![endif]–> around your javascript, this way all other browsers ignores the javascript.

Viewing 1 replies (of 1 total)
  • The topic ‘PNG Fix for IE on backgrounds’ is closed to new replies.