I found many option of checking if the URL contains some text but I am trying to do the opposite.
How can I start a function if the URL DOES NOT contain 'text'?
Here is what I started with that does fire the function but only if the url contains it:
if (document.location.href.indexOf('text') > -1){
alert('URL should not have "text" in it');
}
I tried adding a '!' and a 'NOT' in front of the '(document...' but I guess that's not it.
if (document.location.href.indexOf('text') === -1){
alert('URL should not have "text" in it');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With