该脚本可以工作,但它们似乎是导致第一个和最后一个if语句实现该样式的错误,无论该页面处于何种页面。中间的if语句不显示。多个if语句返回取决于URL的css值
我也尝试了一个休息和每个if语句后返回,但完全刹车脚本,并不显示任何内容。
window.onload = function()
{
var ThisStyle = "background-color: #4C4C4C; color: #fff; -webkit-border-top-right-radius: 15px; -webkit-border-bottom-right-radius: 15px; -moz-border-radius-topright: 15px; -moz-border-radius-bottomright: 15px; border-top-right-radius: 15px; border-bottom-right-radius: 15px;"
if (document.URL.indexOf("index.php"))
{
document.getElementById("home-nav").style.cssText = ThisStyle;
}
else if (document.URL.indexOf("about.php"))
{
document.getElementById("about-nav").style.cssText = ThisStyle;
}
else (document.URL.indexOf("products.php"))
{
document.getElementById("products-nav").style.cssText = ThisStyle;
}
}
任何人有任何想法我做错了什么?
你有一个''如果在'其他失踪(document.URL.indexOf( “products.php”))' – 2015-03-31 13:15:13
即使与变化问题仍然存在 – 2015-03-31 13:17:07
需要使用类而不是http://jsfiddle.net/arunpjohny/h8z4h9qn/4/ – 2015-03-31 13:17:49