javascript - how to know if url path contains some string -


i may have following urls:

localhost/mysite localhost/mysite/index.php localhost/mysite/#hashstring localhost/mysite/index.php/#hasstring localhost/mystie/index.php/path localhost/mysite/index.php/path#hashstring localhost/mystie/index.php/someotherpath 

so in above urls want check if there path string after index.php. /index.php/path, /index.php/path#hashstring, , index.php/someotherpath should return true other urls should return false.

try way:

function check(){  var str = "localhost/mysite/index.php/#hasstring";  var flag = false;  var idx = str.indexof("index.php/");]  var length = str.length;   if( idx >= 0 && length > idx){    flag = true  }  return flag 

}


Comments