由于 IE 无法淡化透明 PNG,我决定更改我的功能,以便在用户使用 IE 时仅显示 PNG,但如果用户使用任何其他浏览器则淡化它们。下面的函数在 IE 中运行良好,并且符合我的预期,但在任何其他浏览器(即 Firefox、Safari)中它什么也没做,是我遗漏了什么还是有语法错误?
$('#content2 a').click(function(){
if($.browser.msie){
var toLoad = $(this).attr('href')+' #content';
$('#content').show(loadContent);
window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
function loadContent() {
$('#content').load(toLoad,'',showNewContent())
}
function showNewContent() {
$('#content').show();
}
return false;
}else{
var toLoad = $(this).attr('href')+' #content';
$('#content').fadeOut('slow',loadContent);
$('#load').remove();
$('#wrapper').append('<span id="load">LOADING...</span>');
$('#load').fadeIn('slow');
window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
function loadContent() {
$('#content').load(toLoad,'',showNewContent())
}
function showNewContent() {
$('#content').fadeIn('slow',hideLoader());
}
function hideLoader() {
$('#load').fadeOut('slow');
}
return false;
};
});