You can check if a string contains substring in javascript by taking the URL using windows.location.href and then check the sub-string using .IndexOf("Substring") method , so your complete code will be as below