arrays - Check if url has given words Jquery? -
I have some URLs, which I have to show some jazzery functions, but will be linked to the URL of time, Now I have something like this,
var loc = window.location.pathname; Var pagean = 'project / node'; If (loc.indexOf (pageOne)> = 0) {// do something} The problem is that the page one, later I will have so many pages, and I This is something like something in the array.
// A simple array with my creator var myArray = new array ("project / node", "setting /"); And then to check if any word in the URL is from the array and do something
then do this,
var loc = window.location.pathname; Var myArray = New Array ("Project / Node", "Settings /"); Var isFound = false; For (Var i = 0, len = myArray.length; i & lt; len; i ++) (if (loc.indexOf (myArray [i])> gt; -1) {isFound = true; breakdown;} } If (ifound) {// do something}
Comments
Post a Comment