Reputation: 59
I'm trying to make something happen if the url contains a certain word, but the word needs to change from page to page, heres the code I've got…
if(window.location.href.indexOf('mens-' || 'footwear-') > -1 ){
// do something here
} else {}
this works for 'mens-' but not for 'footwear-'
any ideas?
Thanks
Upvotes: 0
Views: 336
Reputation: 17091
Agree with @Satpal, but you can try use regex, like this:
if (/(mens-|footwear-)/.test(window.location.href)) {
// do something here
} else {}
It is super simple example... and here I just try to get a gist...
Upvotes: 1