What I want to do is use a variable with window.location.href.indexOf () This is my code right now, I want to shorten it.
var urls = [
'https://www.example.com/'
,'https://www.example2.com/'
,'https://www.example3.com/'
,'https://www.example4.com/'
,'https://www.example5.com/'
];
// if ((window.location.href.indexOf(""+urls+"") > -1) Does not work
if (
(window.location.href.indexOf("https://www.example.com/") > -1)
|| (window.location.href.indexOf("https://www.example2.com/") > -1)
|| (window.location.href.indexOf("https://www.example3.com/") > -1)
|| (window.location.href.indexOf("https://www.example4.com/") > -1)
|| (window.location.href.indexOf("https://www.example5.com/") > -1)
) {
//do stuff
}
I included what I tried in the code, but it does not work. javascript and jquery work for me
source
share