我在http://jquery.malsup.com/fadetest.html找到了一個更好,更一般的解決方案。
我已經採取和調整成JavaScript文件被包含在使用jQuery的淡入淡出*()方法的頁面獨立。
//
// jQuery IE Fade Fix
//
// Adapted from code found at http://jquery.malsup.com/fadetest.html.
//
// This is only needed for IE 7 and earlier, so this is best added to your page using IE's conditional comments
// (http://msdn.microsoft.com/en-us/library/ms537512%28VS.85%29.aspx) as follows:
// <!--[if lt IE 8]><script type="text/javascript" src="jquery-ie-fade-fix.js"></script><![endif]-->
//
(function($) {
$.fn.fadeIn = function(speed, callback) {
if ($.isFunction(speed) && callback == undefined) {
callback = speed;
speed = 'normal';
}
return this.animate({opacity: 'show'}, speed, function() {
if ($.browser.msie)
{
this.style.removeAttribute('filter');
}
if ($.isFunction(callback))
{
callback.call(this);
}
});
};
$.fn.fadeOut = function(speed, callback) {
if ($.isFunction(speed) && callback == undefined) {
callback = speed;
speed = 'normal';
}
return this.animate({opacity: 'hide'}, speed, function() {
if ($.browser.msie)
{
this.style.removeAttribute('filter');
}
if ($.isFunction(callback))
{
callback.call(this);
}
});
};
$.fn.fadeTo = function(speed, to, callback) {
if ($.isFunction(speed) && callback == undefined) {
callback = speed;
speed = 'normal';
}
return this.animate({opacity: to}, speed, function() {
if (to == 1 && $.browser.msie)
{
this.style.removeAttribute('filter');
}
if ($.isFunction(callback))
{
callback.call(this);
}
});
};
})(jQuery);
編輯:股份有限公司joeformd的修補程序的回調。
EDIT2:在速度不是定義拐角的情況下增加了修復,但回調是-Tomi
那麼,它在它的別名文字淡化然後迅速過濾掉,但它的工作原理是不漂亮。我們也需要淡化過濾器!水壩IE。 – chrisdillon 2009-04-22 17:14:56
StackOverflow的就在這個問題的困擾(當您單擊「加載新的答案」)。我希望其中一個團隊看到這個答案。 – 2009-04-22 17:20:41