我想达到这样的事:jQuery的,如果URL匹配
if(window.location.href.indexOf("http://stackoverflow.com/questions/")){
... then to this
}
但是当URL看起来像这样http://stackoverflow.com/questions/ask/
我想达到这样的事:jQuery的,如果URL匹配
if(window.location.href.indexOf("http://stackoverflow.com/questions/")){
... then to this
}
但是当URL看起来像这样http://stackoverflow.com/questions/ask/
它仍然运行你问一个正则表达式来验证网址吗? – OlivierLi
你的IF条件无论如何都是无效的......你应该这样做:if(window.location.href.indexOf(“http://stackoverflow.com/questions/”)> -1){ ...然后到这个 } –
你会想调查indexOf() – kinakuta