javascript - 在 IE7、IE8 中使用滤镜淡化
问题描述
我有以下淡入代码,可在 IE 9、10 和其他现代浏览器中使用,以便在<select>
元素动态添加到页面时淡入该元素:
function fadeIn(element) {
var op = 0.1;
var timer = setInterval(function() {
if (op >=1 ) {
clearInterval(timer);
}
element.style.opacity = op;
op += 0.1;
}, 50);
}
我需要在 IE 7 和 IE 8 中进行类似的淡入淡出工作。上面的代码不起作用,因为那些旧版浏览器使用filter
style 属性。所以我试图实现这一点,但我找不到好的文档。使用这个文档,以下是我的尝试,使用一个只有一个 body 标签的空 HTML 页面:
JS:
window.onload = function() {
var body = document.body;
var select = document.createElement("select");
var option = document.createElement("option");
var optionText = document.createTextNode("A random choice.");
body.appendChild(select);
option.appendChild(optionText);
select.appendChild(option);
fadeInIE(select);
function fadeInIE(element) {
element.style.filter ="progid:DXImageTransform.Microsoft.Fade(duration=5)";
element.filters[0].Apply();
element.filters[0].Play();
}
}
其他 CSS:
select {
display: block;
margin:0 auto;
margin-bottom: 30px;
width:150px;
}
它不起作用。我应该如何实现filter
以实现类似的淡入效果?
解决方案
推荐阅读
- android - 如何将字符串数组返回到java JNI
- ios - 如何从 Date (2018-09-28 09:42:00 +0000 ) 中提取日期、月份和年份 (dd-MM-yyyy) 而没有日期格式的时间 - iOS swift?
- symfony - Symfony 4 - 登录后重定向用户没有活动
- python - numpy蒙面参差不齐的数组
- javascript - 组件道具在浅层渲染中未更新
- windows - Ngrok windows 自动启动
- sockets - 使用 CG-NAT 的两个设备之间的直接客户端-服务器连接
- react-native - 反应选择器下方的本机按钮
- c# - 具有惰性源/数据流的 TPL 数据流
- android - 顶部有 WMS 图层的地图(在线和离线) - Android