The flower fades and the red and green apricots are small. When swallows fly, green water surrounds others.

Transparent png code of js in IE6

Web Birds on the 15th floor 25829 Browse 0 Comments

Transparent png code of js in IE6
png picture It has good quality. The shadow effect also has no stray edges and is very smooth. If you insert a page, you can add color to the content of the website! More importantly, it improves the image quality of the page without increasing the image size. For pictures with complex backgrounds, such as inserting irregular borders on excessively colored backgrounds, it is very convenient!
However, currently in IE, the inserted. png image with transparent background cannot be displayed normally. IE will automatically add a gray background to the ". png" format picture.
The solution is to add javascript. The specific methods are as follows:
Put the following code in the head area to solve the problem.
code:
<script language="javascript">
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);
</script>You can also add this code to a picture separately:
code:
<span
Style="filter: progid: DXImageTransform. Microsoft. AlphaImageLoader (src='Your picture name. png ', sizingMethod='scale');"></span>Both methods are available


Please specify: Bird Blog » Transparent png code of js in IE6

 tourist
Post my comments Change your identity
Cancel comment

Hi, you need to fill in your nickname and email!

  • Nickname (required)
  • Email (required)
  • website