作者HAPPYEND (搭讪退散)
站内Web_Design
标题[问题] 用png档当背景问题
时间Sun Apr 9 10:38:12 2006
请教各位高手帮我这位新手解决这个问题
原本我已经解决了插入图片(格式PNG档)出现蓝背景的问题
我用的软体是frontpage
但是在储存格TD里面使用 background="档案名称.png"(用png当储存格背景)
蓝色的底又跑出来了
orz
如何解决这个问题?
先说我之前解决的方式
(可解决插入图片後用IE浏览没蓝背景的问题)
在<head>和</head>之间加入以下
<!--[if gte IE 5.5000]><script type="text/javascript" src="js/pngfix.js">
</script>
<![endif]-->
pngfix.js的内容是
// Correctly handle PNG transparency in Win IE 5.5 or higher.
//
http://homepage.ntlworld.com/bobosola. Updated 02-March-2004
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);
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.136.228.62
1F:推 blackbing:储存png档的时候记得存成索引色,不要存成RGB 04/13 19:02
2F:推 blackbing:试试看,应该能解决~ 04/13 19:05
3F:→ HAPPYEND:可以罗~谢谢:D 04/15 13:56