jQuery如果url匹配

时间:2012-05-11 19:46:50

标签: jquery

我希望达到这样的目标:

if(window.location.href.indexOf("http://stackoverflow.com/questions/")){
 ... then to this
}

但是当网址看起来像http://stackoverflow.com/questions/ask/

时,它仍会运行

1 个答案:

答案 0 :(得分:13)

if(window.location.href === "http://stackoverflow.com/questions/"){
    ... then to this
}