if(loc_array[loc_array.length-1] == 'index.html'){
//do something
}else{
//something else.
}
In the event that your server serves the same file for "index.html" and "inDEX.htML" you can also use: .toLowerCase()
.
(如果您的服务器为“ index.html”和“ inDEX.htML”提供相同的文件,则您也可以使用: .toLowerCase()
。)
Though, you might want to consider doing this server-side if possible: it will be cleaner and work for people without JS.
(但是,如果可能的话,您可能要考虑在服务器端进行此操作:它将更加干净,并且可以在没有JS的情况下使用。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…