2012-02-06 77 views

回答

5

你能做到這樣的,如果你正在尋找只是該參數並沒有獲准在URL別人面前:

if (window.location.search.indexOf("?TEST=NEWJERSEY") != -1) { 
    // it is present 
} 

如果你想允許的不只是單一的參數更多所以可能會有其他參數?並以任何順序,那麼你可以這樣檢查:

if (window.location.search.match(/(\?|&)TEST=NEWJERSEY($|&)/)) { 
    // it is present 
}