JavaScript Set background transparency effect code

Source: Internet
Author: User
Keywords Web page production Ajax javascript
Tags ajax code document html http javascript microsoft navigator

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>

Related Article

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.