-------------------------------------------------------------------------------------------------------
让IE6支持PNG格式的图片
用法:
先复制下面的代码在记事本中,然后另存为pngbehavior.htc(名字可以任意):
复制代码代码如下:
public:component lightWeight="true"
public:attach event="onpropertychange" onevent="propertyChanged()" /
public:attach event="onbeforeprint" onevent="beforePrint()" for="window"/
public:attach event="onafterprint" onevent="afterPrint()" for="window"/
script
var supported = /MSIE ((5.5)|[6789])/.test(navigator.userAgent)
navigator.platform == "Win32";
var realSrc;
var blankSrc = "https://www.rkxy.com.cn/dnjc/blank.gif";
var isPrinting = false;
if (supported) fixImage();
function propertyChanged() {
if (!supported || isPrinting) return;
var pName = event.propertyName;
if (pName != "src") return;
// if not set to blank
if (!new RegExp(blankSrc).test(src))
fixImage();
};
function fixImage() {
// get src
var src = https://www.rkxy.com.cn/dnjc/element.src;
// check for real change
if (src =https://www.rkxy.com.cn/dnjc/= realSrc/.png$/i.test(src)) {
element.src = https://www.rkxy.com.cn/dnjc/blankSrc;
return;
}
if ( ! new RegExp(blankSrc).test(src)) {
// backup old src
realSrc = https://www.rkxy.com.cn/dnjc/src;
}
// test for png
if (/.png$/i.test(realSrc)) {
// set blank image
element.src = https://www.rkxy.com.cn/dnjc/blankSrc;
// set filter
element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft."
"AlphaImageLoader(src=https://www.rkxy.com.cn/dnjc/’"src"’,sizingMethod=’scale’)";
}
else {
// remove filter
element.runtimeStyle.filter = "";
}
}
function beforePrint() {
isPrinting = true;
element.src = https://www.rkxy.com.cn/dnjc/realSrc;
element.runtimeStyle.filter = "";
realSrc = https://www.rkxy.com.cn/dnjc/null;
}
function afterPrint() {
isPrinting = false;
fixImage();
}
/script
/public:component
最后在你的css文件里面加上这么一段代码:
img {behavior: url(pngbehavior.htc);}
推荐阅读
- 怎样让你大A的敏感信息保密
- Apeaksoft Video Editor裁剪视频的方法
- 昨日不复来的下一句
- qq浏览器怎么允许视频独立播放
- 西装里的衬衫是不是也要干洗
- Win8/Win8.1的IE11闪退的多种解决方案
- secure eraser pro清理系统注册表的方法
- 360安全浏览器怎么安装fatkun图片批量下载插件
- 微信定位怎么关闭
- CSS对IE6、IE7、IE8支持详细的易用的参考