Full code snippet to make PNG icon transparent in IE6

Source: Internet
Author: User

A reference to the IE6 in the IMG icon can also reference PNG image JS plug-in code of the HTML is written in this way, compatible with IE6:

<a class= "btn btn-select" href= "javascript:fensong_addaccept ()" >
<span class=" Addtxt "> Add sending Units </ Span></a>

Attention:

1, in order to achieve display:inline-block; effect, in IE6 must add _zoom:1;_display:inline; So two properties to be compatible

2, line-height:16px; be sure to write, because the height of the icon is 16, but the parent element's Row height property affects the img tag in IE6, so the row height value is clearly defined, otherwise the icon is stretched

3, quoted the following transparent JS code to locate the IMG tag, you must write the style inside the line, otherwise invalid. Sweat, several pits, practice the truth Ah!

4. As long as the following JS code snippet is referenced in the page, the IMG tag can be arbitrarily written anywhere on the page.

JS Plugin code: You can make all the IMG tags in a project that reference PNG images fully transparent

function Correctpng ()
{
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);

Full code snippet to make PNG icon transparent 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.