我可能有以下网址:
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
所以在上面的网址中我想检查一下index.php之后是否有一些路径字符串。因此/index.php/path, /index.php/path#hashstring, and index.php/someotherpath
应返回true ,但其他网址应返回false。
答案 0 :(得分:-1)
尝试这种方式:
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
}