我目前单独搜索 window.location.href :
window.location.href:http://www.example.com/6CATA/folder/file.html
var searchWinHref = window.location.href;
if(searchWinHref.indexOf("/6CATA/") > -1) {
alert('6CATA is in the window.location.href');
}
这会触发警报。
如何调整它以查询变量 searchWinHref 以匹配数组中的字符串之一?
var searchWinHref = window.location.href;
var searchWinArray = ['6CATA', '6CATB', '6CATC'];
if(searchWinHref.indexOf(searchWinArray)) {
alert('alert which code is in the window.location.href');
}