Insert this code into the head ..
<Script language = "JavaScript" type = "text/JavaScript"> <br/> function correctpng () <br/>{< br/> for (VAR I = 0; I <document. images. length; I ++) <br/>{< br/> var IMG = document. images <br/> var imgname = IMG. SRC. touppercase () <br/> If (imgname. substring (imgname. length-3, imgname. length) = "PNG") <br/>{< br/> var imgid = (IMG. ID )? "Id = '" + IMG. ID + "'": "" <br/> var imgclass = (IMG. classname )? "Class = '" + IMG. classname + "'": "" <br/> var imgtitle = (IMG. Title )? "Title = '" + IMG. title + "'": "Title ='" + IMG. alt + "'" <br/> var imgstyle = "display: inline-block;" + img.style.css text <br/> If (IMG. align = "Left") imgstyle = "float: Left;" + imgstyle <br/> If (IMG. align = "right") imgstyle = "float: right;" + imgstyle <br/> If (IMG. parentelement. href) imgstyle = "cursor: hand; "+ imgstyle <br/> var strnewhtml =" <span "+ imgid + imgclass + imgtitle <br/> +" style = \ "" + "width:" + IMG. width + "PX; Height:" + IMG. height + "PX;" + imgstyle + ";" <br/> + "filter: progid: DXImageTransform. microsoft. alphaimageloader "<br/> +" (src = \ '"+ IMG. SRC + "\ ', sizingmethod = 'Scale'); \"> </span> "<br/> IMG. outerhtml = strnewhtml <br/> I = I-1 <br/>}< br/> window. attachevent ("onLoad", correctpng); <br/> </SCRIPT> </P> <p>
Or:
Insert this into the required page:
<! -- [If lt IE 7]> <br/> <SCRIPT defer type = "text/JavaScript" src = "PNG. js"> </SCRIPT> <br/> <! [Endif] --> </P> <p>
Save as follows: PNG. js call
VaR arversion = navigator. appversion. split ("MSIE") <br/> var version = parsefloat (arversion [1]) <br/> If (version >=5.5) & (document. body. filters) <br/>{< br/> for (VAR I = 0; I <document. images. length; I ++) <br/>{< br/> var IMG = document. images [I] <br/> var imgname = IMG. SRC. touppercase () <br/> If (imgname. substring (imgname. length-3, imgname. length) = "PNG") <br/>{< br/> var imgid = (IMG. ID )? "Id = '" + IMG. ID + "'": "" <br/> var imgclass = (IMG. classname )? "Class = '" + IMG. classname + "'": "" <br/> var imgtitle = (IMG. Title )? "Title = '" + IMG. title + "'": "Title ='" + IMG. alt + "'" <br/> var imgstyle = "display: inline-block;" + img.style.css text <br/> If (IMG. align = "Left") imgstyle = "float: Left;" + imgstyle <br/> If (IMG. align = "right") imgstyle = "float: right;" + imgstyle <br/> If (IMG. parentelement. href) imgstyle = "cursor: hand; "+ imgstyle <br/> var strnewhtml =" <span "+ imgid + imgclass + imgtitle <br/> +" style = \ "" + "width:" + IMG. width + "PX; Height:" + IMG. height + "PX;" + imgstyle + ";" <br/> + "filter: progid: DXImageTransform. microsoft. alphaimageloader "<br/> +" (src = \ '"+ IMG. SRC + "\ ', sizingmethod = 'Scale'); \"> "<br/> IMG. outerhtml = strnewhtml <br/> I = I-1 <br/>}< br/> </document> <br/>
Both methods can solve the problem of changing the transparency of PNG images in the webpage to Gray ~~ Add: the above method can only insert images on the page for . It cannot be applied to PNG images in the background. In this case, you need to insert the following code to the background image in CSS: filter: progid: DXImageTransform. microsoft. alphaimageloader (Enabled = true, src = absolute path,); this code is also found from the Internet and is very useful. paste the original description below: alphaimageloader compatibility: ie5.5 + compiler method:
Filter: progid: DXImageTransform. Microsoft. alphaimageloader (Enabled = benabled, sizingmethod = ssize, src = Surl)Adequacy:
Enabled: Optional. Boolean ). Whether the device or the zookeeper is activated. True | false true: the default value. Zookeeper is activated.
False: deny is disabled.
Sizingmethod: Optional. String ). The display method of the photo clip used by the preset or sortline operator in the photo container's border. Crop: Cut the clip to apply the size of the target image.
Image: the default value. Increase or decrease the size of the image.
Scale: scale the size of the photo to match the image.
SRC: required. String ). Specify the background image using either the opposite URL or the opposite URL. If this parameter is ignored, the specified parameter will not work.
Features:
Enabled: You can renew your subscription. Boolean ). Zookeeper enabled authentication.
Sizingmethod: Optional values. String ). Inclu sizingmethod adequacy.
SRC: Optional values. String ). Using the SRC connector.
Solution IE8 does not support transparent filters:Write filter: alpha (opacity = 50), which is not supported by ie8.
This method does not know what to solve-MS-filter: "progid: DXImageTransform. Microsoft. Alpha (opacity = 50 )";
In IE7 and IE8, you can write filter: progid: DXImageTransform. Microsoft. Alpha (opacity = 50 );
In Firefox, you can write: opacity: 0.5.