我希望达到这样的目标:
if(window.location.href.indexOf("http://stackoverflow.com/questions/")){
... then to this
}
但是当网址看起来像http://stackoverflow.com/questions/ask/
答案 0 :(得分:13)
if(window.location.href === "http://stackoverflow.com/questions/"){
... then to this
}