我对此完全感到困惑。在我调用“setCookie”的那一行,如果第二个函数参数与上面的 current_cat OR 比较相同(即“art”),则整个 if 语句都会中断(并且函数不会在其中调用)。如果我更改参数使其不匹配(即“art_z”),则代码有效。多个“if”块会出现问题;但该代码仅适用于一个“if”块。没有多少黑客可以解决这个问题 - 有什么想法吗?提前非常感谢。
var current_cat = getCookie("FOF_CURRENT_CATEGORY");
if (menuitem == "menu_art" || current_cat == "art")
{
document.getElementById("menu_arc").className = "amble12graylight";
document.getElementById("menu_art").className = "amble14blackregular";
document.getElementById("menu_des").className = "amble12graylight";
document.getElementById("menu_fas").className = "amble12graylight";
document.getElementById("menu_sch").className = "amble12graylight";
document.getElementById("menu_man").className = "amble12graylight";
setCookie("FOF_CURRENT_CATEGORY","art",365);
}
if (menuitem == "menu_arc" || current_cat == "arc")
{
document.getElementById("menu_arc").className = "amble14blackregular";
document.getElementById("menu_art").className = "amble12graylight";
document.getElementById("menu_des").className = "amble12graylight";
document.getElementById("menu_fas").className = "amble12graylight";
document.getElementById("menu_sch").className = "amble12graylight";
document.getElementById("menu_man").className = "amble12graylight";
setCookie("FOF_CURRENT_CATEGORY","arc",365);
}