Javascript 带有颜色插件转换的jQuery.animate()在Firefox中闪烁
我正在尝试创建一个菜单,在单击项目时,该菜单将链接更改为文本(从选定项目中删除超链接功能),并将颜色从“常规链接”平滑更改为“选定”颜色。我的代码可以在任何地方使用,除了Firefox的更新版本。FF会导致转换闪烁 我的菜单是在页面加载时动态创建的。名为“createInitial()”的函数负责此操作:Javascript 带有颜色插件转换的jQuery.animate()在Firefox中闪烁,javascript,jquery,firefox,colors,flicker,Javascript,Jquery,Firefox,Colors,Flicker,我正在尝试创建一个菜单,在单击项目时,该菜单将链接更改为文本(从选定项目中删除超链接功能),并将颜色从“常规链接”平滑更改为“选定”颜色。我的代码可以在任何地方使用,除了Firefox的更新版本。FF会导致转换闪烁 我的菜单是在页面加载时动态创建的。名为“createInitial()”的函数负责此操作: function createInitial(){ // BLA-BLA-BLA SOME CODE //construct menu
function createInitial(){
// BLA-BLA-BLA SOME CODE
//construct menu
for(i=0; i<pages.length; i++){ //for every item of pages[] array
$dashLink = $("<a>");
$dashLink.html(pages[i].title);
$dashLink.attr("href", "javascript:void(0)");
$dashLink.attr("id", "dashLink" + i); //create a link for a particular page (with matching ID field)
$dashLink.click(menuHandler);
$dashText = $("<span>");
$dashText.html(pages[i].title);
$dashText.attr("id", "dashText" + i); //create a text (to be used instead of a link, while on a page) for a particular page
$dashText.css("display", "none");
$("#menu").append("[ ", $dashLink, $dashText, " ] "); //add links and texts to same bracket space in the menu
}
//
//creates default text instead of a link
$("#dashLink" + currentPage).css("display", "none");
$("#dashText" + currentPage).css("display", "inline");
//
// BLA-BLA-BLA SOME CODE
}
这段代码在任何地方都能完美运行(即使在IE中),除了Firefox的较新版本(不确定,但可能只在Windows上)。我已经在LinuxMint上测试了Firefox12,它的工作非常出色。然而,当在Windows上使用Firefox 15进行测试时,转换闪烁得很厉害!我发现了几个线程,人们都有类似的问题,但大多数线程对于FF15来说太老了。以下是我尝试过的几个链接:
-
-
-
不幸的是,没有任何帮助。有人知道问题出在哪里吗?谢谢 现代Firefox如何处理CSS的已知问题现代Firefox如何处理CSS的已知问题
function changeHeader(page){ //change a page
//stop all previous animation
$("#heading").stop();
$("#content").stop()
$("#menu a").stop(true);
$("#menu span").stop(true);
//
//change current page to new, store current page id
tempPage = currentPage;
currentPage = page;
//
//record current changing menu items color state
currentPageLinkTextColor = $("#dashText" + tempPage).css("color"); // starting point for current page menu text item
nextPageLinkColor = $("#dashLink" + page).css("color"); //starting point for clicked page menu link item
//
//show current page menu item as link and start chaging to link color
$("#dashLink" + tempPage).css("color", currentPageLinkTextColor);
$("#dashText" + tempPage).hide();
$("#dashLink" + tempPage).show();
$("#dashLink" + tempPage).animate({color: linkColor}, transitionTime*2);
//
//show next page menu item as text and start changing to text color
$("#dashText" + page).css("color", nextPageLinkColor);
$("#dashLink" + page).hide();
$("#dashText" + page).show();
$("#dashText" + page).animate({color: linkTextColor}, transitionTime*2);
//
$("#menu a").animate({color: linkColor}, transitionTime*2); //change all menu links to link color
//changes title
$("#heading").fadeOut(transitionTime, function() { //fade out / fade in title
$("#heading").html(pages[page].title)
$("#heading").fadeIn(transitionTime)
});
//
}