添加js代码后png图片就看不见了? 还没用过PNG来当透明图,通常只用GIF,可能是颜色位数不同,所以很多人喜欢用PNG。但听说IE对PNG透明图支持不好。你最好把代码和图片地址帖出来,方便大家帮你找原因。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script language="javascript" type="text/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.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 } } }window.attachEvent("onload", correctPNG);</script><html xmlns="http://www.w3.org/1999/xhtml" ><head id="Head1" runat="server"> <title>无标题页</title></head><body> <form id="form1" runat="server"> <img src="images/jggz/a1.png" /><div> </div> </form> </body></html> 不加script就可以看见图片 加了就看不见了 再来一个生成页面的原文件<script language="javascript" type="text/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.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 } } }window.attachEvent("onload", correctPNG);</script><html xmlns="http://www.w3.org/1999/xhtml" ><head id="Head1"><link href="App_Themes/%E9%BB%98%E8%AE%A4%E4%B8%BB%E9%A2%98/StyleSheet.css" type="text/css" rel="stylesheet" /><title> 无标题页</title></head><body> <form name="form1" method="post" action="测试.aspx" id="form1"><div><input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNzgzNDMwNTMzZGRkKep7mTQi4w74cTQ9bryWyEdmQA==" /></div> <img src="images/jggz/a1.png" /><div> </div> </form> </body></html> 原来是加滤镜啊~~滤镜俺不熟~~~调试的方法是,看看js执行过后html代码变成什么样子了~~<input type="button" onclick="alert(document.body.innerHTML)" />看看图片还在不在~~在确定图片还在的情况下,如果说看不见了可能是透明度设置成100%透明了吧~~? 问个正则表达式的验证 mooTools小练习,绷紧你的视觉神经。 return的问题 谁知道如何获取文件名前面的文字啊. 求帮忙改一点代码,关于div定位的问题 JS控制Div的问题 我用了showModalDialog,怎么改变对话框的标题啊? 关于锚点,急问! 最新技术,全新的B/S结构开发方式,用纯JS+HTML实现了类似C/S的强大浏览器交互,查询及分页浏览速度提高几倍,可以成批录入数据,有完整的数据库表访问和纯web打印,统计图等 jquery中这种写法疑似木有 谁能提供一个漂亮的气泡提示框特效 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.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
}
}
}
window.attachEvent("onload", correctPNG);
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<img src="images/jggz/a1.png" /><div>
</div>
</form>
</body>
</html>
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
}
}
}
window.attachEvent("onload", correctPNG);
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1"><link href="App_Themes/%E9%BB%98%E8%AE%A4%E4%B8%BB%E9%A2%98/StyleSheet.css" type="text/css" rel="stylesheet" /><title>
无标题页
</title></head>
<body>
<form name="form1" method="post" action="测试.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNzgzNDMwNTMzZGRkKep7mTQi4w74cTQ9bryWyEdmQA==" />
</div> <img src="images/jggz/a1.png" /><div>
</div>
</form>
</body>
</html>
<input type="button" onclick="alert(document.body.innerHTML)" />
看看图片还在不在~~在确定图片还在的情况下,如果说看不见了可能是透明度设置成100%透明了吧~~?