<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>javascript Set background transparency effect code </title>
<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.css tutorial text;
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;
}
}
}
function Alphabackgrounds () {
var rslt = Navigator.appVersion.match (/msie (d+.d+)/, "");
var Itsallgood = (rslt!= null && number (RSLT[1)) >= 5.5);
For (i=0 i<document.all.length; i++) {
var bg = document.all[i].currentstyle.backgroundimage;
if (BG) {
if (Bg.match (/.png/i)!= null) {
var mypng = bg.substring (5,bg.length-2);
alert (mypng);
Document.all[i].style.filter = "Progid:DXImageTransform.Microsoft.AlphaImageLoader" (src= ' +mypng+ ', sizingmethod= ' Crop ') ";
document.all[i].style.backgroundimage = "url (')";
alert (Document.all[i].style.filter);
}
}
}
}
if (Navigator.platform = = "Win32" && navigator.appname = "Microsoft Internet Explorer" && Window.attache Vent) {
Window.attachevent ("onload", correctpng);
Window.attachevent ("onload", alphabackgrounds);
}
</script>
<body>
</body>