如何清除透明png图片的阴影 做的透明png图片,但是放到网页上是浅蓝色的背景,请问如何清除这个背景。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 直接<img src="x.png" />还是<a href=""><img src="x.png" /></a>显示的? 把背景设成白色的,一般来说应该没有问题的,只是png的图片比较大 把这段代码加上就好了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 } } } 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); document.all[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + mypng + "', sizingMethod='crop')"; document.all[i].style.backgroundImage = "url('')"; } } } } if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) { var ua =navigator.userAgent.toLowerCase(), ie=0; if (window.ActiveXObject) ie=parseInt(ua.match(/msie ([\d.]+)/)[1]); if(ie==6){ window.attachEvent("onload", correctPNG); window.attachEvent("onload", alphaBackgrounds); } } 有没有开发过WebApp的? 网页版摄像头输入 人脸检测 如何判断radio和select是否选中? 我的网页总让人注入如下代码,怎么办? 一个表单中,有多个相同name的输入框,怎么去一一验证每个都不为空? 急,下面这段代码,用VBSCRIPT怎么写的? 谁会写这个javascript函数? 非常棘手的一个问题,请大家帮忙 可用分捐赠[2003-1-13=>2003-1-25] Total 5786 如何实现象kali.com.cn一样,将鼠标移到动态数据上时,下面出现文本提示框? 问一下 ssl加密后页面有指向其他网站的地址Ie8下面出现提示
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
}
}
} 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);
document.all[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + mypng + "', sizingMethod='crop')";
document.all[i].style.backgroundImage = "url('')";
}
}
}
} if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
var ua =navigator.userAgent.toLowerCase(),
ie=0;
if (window.ActiveXObject)
ie=parseInt(ua.match(/msie ([\d.]+)/)[1]);
if(ie==6){
window.attachEvent("onload", correctPNG);
window.attachEvent("onload", alphaBackgrounds);
}
}