JavaScript Tutorial Set Background transparency effect code
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.jzread.com/1999/xhtml" >
<head>
<meta http-equiv= "Content-type content=" 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.attachevent) {
window.attachevent ("onload", correctpng);
window.attachevent ("onload", alphabackgrounds);
}
</script>
</head>
<body>
</body>
</html>