Resolving PNG images in IE6 background opacity method _ resolving PNG back in IE6

Source: Internet
Author: User

Resolving PNG images in IE6 background opacity method _ resolving PNG back in IE6
Directory
  1. Resolving code
  2. Resolving PNG images in HTML
  3. Resolving PNG as a Web page background-css
1, to solve the PNG image in the IE6 background opaque CSS and JS code-TOP

JS Code

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 j=0; j<document.images.length; J + +)
{
var img = document.images[j]
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
j = J-1
}
}
}
}
Window.attachevent ("onload", correctpng);


CSS code:

#id {background:url (picture path); _filter:progid:dximagetransform.microsoft.alphaimageloader (enabled= ' true ', sizingmethod= ' scale ', src= "picture path"); _background:none;}


2. Resolving PNG images in HTML IMG tags using PNG images IE6 background Opaque method-TOP

1, create a new JS file for Iepngfx.js, into the above JS code copied into the JS file
2, in the HTML declaration only IE6 read this new JS file iepngfx.js
Only allow IE6 to read this JS file method:
<!--[if IE 6]>
<script src= "Images/iepngfx.js" language= "JavaScript" type= "Text/javascript" ></script>
<! [endif]-->
3, using the image tag img in HTML using PNG images, try to IE6 PNG picture background is transparent.

3, in CSS as the background of the Web page in the IE6 background transparent method-TOP

Same method
1, the new JS file ibid, named Iepngfx.js, into the above JS code copied into the JS file
2, in the HTML declaration only IE6 read this new JS file iepngfx.js
Only allow IE6 to read this JS file method:
<!--[if IE 6]>
<script src= "Images/iepngfx.js" language= "JavaScript" type= "Text/javascript" ></script>
<! [endif]-->
3. Add the following CSS code where the PNG image is used as the background in CSS:

#id {background:url (picture path); _filter:progid:dximagetransform.microsoft.alphaimageloader (enabled= ' true ', sizingmethod= ' scale ', src= "picture path"); _background:none;}

This resolves PNG images in HTML img as Picture icon backgrounds cannot be transparent or PNG images as Web background background apply the same as the implementation of PNG picture background transparency.

The following JS and CSS methods for resolving PNG images in IE6 are useful for you in the background opacity method.

Resolving PNG images in IE6 background opacity method _ resolving PNG back in IE6

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.